Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Data structure for screen flow

 
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • 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
 
Bartender
Posts: 7202
65
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Mark post as helpful
  • send pies
  • 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
  • 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
Bartender
Posts: 7202
65
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Yes. Good catch.
Any idea on the implementation logic ?
Thank you!
 
Carey Brown
Bartender
Posts: 7202
65
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Mark post as helpful
  • send pies
  • 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.
 
You will always be treated with dignity. Now, strip naked, get on the probulator and hold this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic