1 / 30

CSC 364 001 Data Structures and Algorithms Lee Weiner 572-6025 weinerl@nku

CSC 364 001 Data Structures and Algorithms Lee Weiner 572-6025 weinerl@nku.edu. Student - lastName : String - firstName : String - state : String - major : String + createStudent() + getFirstName() : String + setFirstName() : void + getLastName() : String + setLastName() : void

eldridged
Download Presentation

CSC 364 001 Data Structures and Algorithms Lee Weiner 572-6025 weinerl@nku

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSC 364 001 Data Structures and Algorithms Lee Weiner 572-6025 weinerl@nku.edu

  2. Student - lastName : String - firstName : String - state : String - major : String + createStudent() + getFirstName() : String + setFirstName() : void + getLastName() : String + setLastName() : void + getState() : String + setState() : void + getMajor() : String + setMajor() : void + getRate() : int - isStateValid(): boolean - isMajorValid() : boolean Student - lastName : String - firstName : String - state : String - major : String + createStudent() + getFirstName() + setFirstName() + getLastName() + setLastName() + getState() + setState() + getMajor() + setMajor() + getRate() - isStateValid() - isMajorValid() Student - lastName : String - firstName : String - state : String - major : String + createStudent() + getFirstName() + setFirstName() + getLastName() + setLastName() + getState() + setState() + getMajor() + setMajor() + getRate() - isStateValid() - isMajorValid()

  3. Lee Dan Joe Bob aaaa cccc ffff null abcd abcd aaaa cccc ffff head

  4. Node - data : Object - link : Node + createNode() + getData() : Object + setData() : void + getLink() : Node + setLink() : void

  5. Lee Dan Joe Bob Barb aaaa cccc ffff null cccc abcd abcd aaaa cccc ffff xxxx head link = new Node( data, link );

  6. Lee Dan Joe Bob Barb aaaa xxxx ffff null cccc abcd abcd aaaa cccc ffff xxxx head

  7. Lee Dan Joe Bob aaaa cccc ffff null abcd abcd aaaa cccc ffff head link = link.link;

  8. Lee Dan Joe Bob aaaa ffff ffff null abcd abcd aaaa cccc ffff head

  9. Node - data : Object - link : Node + createNode() + getData() : Object + setData() : void + getLink() : Node + setLink() : void + addNodeAfter() : void + removeNodeAfter() : void

  10. Node current = head; while( current != null ) { System.out.println( current.getData() ); current = current.getLink(); } Traversing a Linked List

  11. if( head == null ) head = new Node( data, null ); else { Node current = head; while( current.getLink() != null ) current = current.getLink(); current.addNodeAfter( data ); } Adding a Node to the End of the List

  12. LinkedList - head : Node + createLinkedList() + add(Object) + add(Object, int) + clear() + get(int) : Node + isEmpty() : boolean + size() : int + find(Object) : int + remove(Object) + remove(int) - getReference(int) : Node

  13. Node - data : Object - link : Node + createNode() + getData() + setData() + getLink() + setLink() + addNodeAfter() + removeNodeAfter() LinkedList - head : Node + createLinkedList() + add(Object) + add(Object, int) + clear() + get(int) : Node + isEmpty() : boolean + size() : int + find(Object) : int + remove(Object) + remove(int) - getReference(int) : Node 0..* 1 UML “Has A” Relationship

  14. Employee - home : HomeAddress - job : JobInfo - insurance : Insurance - ssn : String - lastName : String - firstName : String + createEmployee() + getSSN() : String + setSSN() + getFirstName() : String + setFirstName() + getLastName() : String + setLastName() HomeAddress - street : String - addr2 : String - city : String - state : String - zip : String + getStreet() : String + setStreet() + getAddr2() : String + setString() . . . JobInfo - jobCode : String - title : String - salary : String - location : JobAddress - startDate : Date + getJobCode() : String + setJobCode() + getTitle() : String + setTitle() . . . 1 1 1 0..* Another Use of "Has A"

  15. Stacks

  16. Stack - stack : LinkedList + createStack() + push( Object ) + pop() : Object + peek() : Object + isEmpty() : boolean

  17. Queues

  18. Queue - queue : LinkedList + createQueue() + enqueue( Object ) + dequeue() : Object + size() : int + isEmpty() : boolean

  19. 1 2 3 3 4 Priority Queue

  20. 1 2 2 3 4 Priority Queue

  21. 1 2 3 3 4 Priority Queue

  22. 1 2 1 3 4 Priority Queue

  23. 1 2 3 4 Priority Queue

  24. 1 2 1 3 4 Priority Queue

  25. 1 2 3 4 Priority Queue

  26. 1 2 3 4 Priority Queue

  27. 1 2 3 4 Priority Queue

  28. 1 2 3 4 Priority Queue

  29. enqueue(Object, int) - Add a node in the priority specified by the int • dequeue() - Loop through the priorities, dequeue a node from the highest priority that has one • size() - Loop through all priorities, summing and returning number of nodes. • isEmpty() - If all priorities are empty, return true 4 Queue Methods for Priority Queue

  30. Stack - stack : LinkedList + createStack() + push( Object ) + pop() : Object + peek() : Object + isEmpty() : boolean 1 1 LinkedList - head : Node + createLinkedList() + add(Object) + add(Object, int) + clear() + get(int) : Node + isEmpty() : boolean + size() : int + find(Object) : int + remove(Object) + remove(int) - getReference(int) : Node

More Related