{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Quiz1SolutionsSu98

# Quiz1SolutionsSu98 - front1 = front2 else p = front1...

This preview shows pages 1–3. Sign up to view the full content.

Quiz #1 EEL4851 Summer 1998 Solutions On stacks, queues and general list Part 1. Given the array implementation of single-linked list (next but no prev fields), suppose there are 2 linked list in this array besides the empty list ( three total ). The lists are start with front1 and front2. Write a segment of code to concatenate the two lists. That is, connect the front of the second list to the end of the first list. Conceptually do this: Before: Front1 Front2 After: Front1 Front2 if (front1 == -1)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: front1 = front2; else { p = front1; while (list[p].next != -1) p = list[p].next; list[p].next = front2; front2 = -1; } Part 2. Given the following array, what will the array look like after concatenating the two lists? Before: 1 2 3 4 5 6 7 Fred smith Bill A. Linda Evans Eliza smith Barbara W. 4 1-1 5 2-1 3 7 front1 empty_front front2-1 6 After ?: 1 2 3 4 5 6 7 Fred smith Bill A. Linda Evans Eliza smith Barbara W. front1 empty_front front2 4-1-1 6 2 1 5 3-1 7...
View Full Document

{[ snackBarMessage ]}

### Page1 / 3

Quiz1SolutionsSu98 - front1 = front2 else p = front1...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online