• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Data structure for screen flow

 
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I am looking for building logic in Java for screen flow consolidation. Sample for input and output is below. Can you please suggest what data structure fits best for this scenario.
I was able to build a logic to count screen watch at each level but still thinking over how to come to exact desirable output. Any idea would be appreciated.

Input:
screen1,screen2,screen3,screen4
screen3,screen4,screen5,screen8
screen9,screen2,screen3,screen9,screen10
screen9,screen10,screen11,screen12
screen3,screen4,screen5,screen8
screen3,screen4,screen5,screen8
screen1,screen2,screen3,screen4

Output:
Screen1,2 -> Screen2,2 -> Screen3,2 -> Screen4,4
Screen3,3 -> Screen4,3 -> Screen5,3 -> Screen8,3
Screen9,2, -> Screen2,1 -> Screen3,1 -> Screen9,1 -> Screen10,1
Screen9,1, -> Screen10,1 -> Screen11,1 -> Screen12


Thanks
CM
 
Saloon Keeper
Posts: 10705
86
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, I'm having trouble guessing your requirements based on some sample data. Could you be more specific?
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
carey,

Basically I have input as series of user actions (which all screens of a web page user has visited) e.g. each input line represent individual user's page views.
I want to create a Behavior flow out of it. for example Screen1 is viewed by 2 people followed by Screen2 by 2 people followed by Screen3 by 2 people and so on.
If someone visits Screen4 after Screen2 the output should be Sceen1,2 -> Screen2,2 -> Screen4,1
Value right after Screen name is number of times that screen was viewed by someone.
Hope I am making sense here in the requirement.
 
Carey Brown
Saloon Keeper
Posts: 10705
86
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Chandra Bhatt wrote:
Input:
screen1,screen2,screen3,screen4
screen3,screen4,screen5,screen8
screen9,screen2,screen3,screen9,screen10
screen9,screen10,screen11,screen12
screen3,screen4,screen5,screen8
screen3,screen4,screen5,screen8
screen1,screen2,screen3,screen4

Output:
Screen1,2 -> Screen2,2 -> Screen3,2 -> Screen4,4
Screen3,3 -> Screen4,3 -> Screen5,3 -> Screen8,3
Screen9,2, -> Screen2,1 -> Screen3,1 -> Screen9,1 -> Screen10,1
Screen9,1, -> Screen10,1 -> Screen11,1 -> Screen12


Wouldn't the 2nd output line be
3,3 -> 4,4 -> 5,3 -> 8,3
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes. Good catch.
Any idea on the implementation logic ?
Thank you!
 
Carey Brown
Saloon Keeper
Posts: 10705
86
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Going with the input as you've shown it, you'd have to parse the input string and count the number of instances of each screen. You can do this with a Map<String,Integer> where String would be, for example, "screen1" and Integer would hold a count of occurrences. Secondly, keeping the original String intact, add it to a Set<String>, this will give you the set of all unique entries. Then you have to put the two together to get your output.
 
keep an eye out for scorpions and black widows. But the tiny ads are safe.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic