0% found this document useful (0 votes)
2 views3 pages

Online Class 27-12-2020

The document contains exercises related to data structures, specifically focusing on linked lists, stacks, and queues. It includes questions about reversing a linked list, stack operations, and queue implementations, along with answers for each exercise. Additionally, it requests the creation of a flowchart and a C++ program for removing negative numbers from a queue.

Uploaded by

Kareem Hamdy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Online Class 27-12-2020

The document contains exercises related to data structures, specifically focusing on linked lists, stacks, and queues. It includes questions about reversing a linked list, stack operations, and queue implementations, along with answers for each exercise. Additionally, it requests the creation of a flowchart and a C++ program for removing negative numbers from a queue.

Uploaded by

Kareem Hamdy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Computer Science School

CSC 250 - Data Structures

Online Class: Data Structure Exercise:

1- The following function reverse() is supposed to reverse a singly


linked list. What is the line missing at the end of the function?
(head_ref is the pointer of the first node) (HINT: Check the code
for a linked list having 3 nodes for simplicity)

Answer: head_ref = prev;


------------------------------------------------------------------------------------
2- Consider the following operation performed on a stack of size 5.
How many elements will be present in the stack?

Answer: 1
Computer Science School
CSC 250 - Data Structures

3- Suppose that the input is entered as follows: 14 45 34 23 10 5 0 -


- Show what is the order of the elements popped from the stack.

Answer: 10 34 14 5
----------------------------------------------------------------------------

4- Trace the following code, what will be the output? User inputs
the following sequence of numbers: 4 5 67 89 21 3 0 76 15 75

Answer: 4 5 21 3 15
Computer Science School
CSC 250 - Data Structures

5- Given the following queue (array implementation), containing the


numbers 4, 3, 6, 8 and 9. What are the values of front and rear?

Answer: front = 1, rear = 5

------------------------------------------------------------------------------------
6- Draw the flowchart, then write the C++ program that removes
negative numbers from a queue.
------------------------------------------------------------------------------------
7- Write the main function for the program that implements a queue
using stacks.

Best Wishes

You might also like