Csci1933_midterm2_example (1).pdf - Csci 1933 Midterm Exam...

This preview shows page 1 - 4 out of 9 pages.

The preview shows page 2 - 4 out of 9 pages.
Csci 1933 Midterm Exam #2Monday, November 17, 2017This is a 50 minute closed book exam.You may use 1 page (8.5” x 11”) (2 sides) of handwritten notes.Please keep track of the timeall exams will be collected at the end of the class period (3:20pm).Readall instructions carefully!We will give partial credit, so be sure to show your work and write down even apartial solution.Please read and sign the statement below and be sure to provide all of your info.Goodluck!I certify that the work on this exam is solely the result of my own efforts and that I have used no additionalmaterials other than 1 page of handwritten notes, received no outside help or information, nor in any waycontributed to another’s work during this exam.Signature:__________________________________________Print Name:_________________________________________Student ID Number:____________________QuestionTotalpointspossiblePointsearned125220325430Total100
1.Using Abstract Data Types(25 points)Write the output of the following lines of codeanddraw the state of the data structures whereasked.You can write the output of each part immediately below the corresponding code.Studythe code carefully!public class TestClass {public static void main(String[] args) {// ***** Part a *****QueueInterface<String> q = new LinkedQueue<String>();q.enqueue(“A”);q.enqueue(“B”);q.enqueue(“C”);q.enqueue(“D”);System.out.println(q.getFront());q.dequeue();q.enqueue(q.dequeue());(a)(i) Draw the state of the queue here, indicating the front and backwhile(! q.isEmpty()) {System.out.println(q.dequeue());}(a)(ii) Write the complete output of part (a)// ***** Part b *****StackInterface<String> s = new ArrayStack<String>();s.push(“A”);s.push(“B”);s.push(“C”);s.push(“D”);System.out.println(s.peek());s.pop();s.push(s.pop());(b)(i) Draw the state of the stack here, indicating the top and bottom

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 9 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Spring
Professor
Dovolis,ChrisJohn
Tags
Algorithms, Data Structures, Subroutine, frontIndex

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture