0% found this document useful (0 votes)
11 views

CP 213 Test 1 2023

The document outlines a test for a course on Data Structures and Algorithms Analysis, consisting of various questions related to linked lists, including adding and deleting nodes, and structure definitions. It includes specific tasks such as writing code for manipulating linked lists and defining a structure for a car. The test is designed to assess understanding of pointers and data structure operations.

Uploaded by

Lucky Machaba
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)
11 views

CP 213 Test 1 2023

The document outlines a test for a course on Data Structures and Algorithms Analysis, consisting of various questions related to linked lists, including adding and deleting nodes, and structure definitions. It includes specific tasks such as writing code for manipulating linked lists and defining a structure for a car. The test is designed to assess understanding of pointers and data structure operations.

Uploaded by

Lucky Machaba
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/ 2

CP 213: DATA STRUCTURES AND ALIGORITHMS ANALYSIS

TEST 1 (15 Marks) TIME: 50 Mins DATE: Sunday, 29 January, 2023


Name: _____________________ Reg #: ______________ Program: ____
1. Given that Figure 1, and Figure 2 are linked lists. Numbers 1 through 6 are the
imaginary names of pointers and p, q, x, y are the pointers. Consider that a new
node named Node is to be added to the list, answer the question which follows:

Figure 1: Linked List


Figure 2: Linked List

i. Using Figure 1, mention the pointer(s) which will be involved to join the
Node: (0.5 Marks Each)
a. At the end of the list. _____________________________________
b. At the beginning of the list. ________________________________
c. After the second node. ____________________________________
ii. To complete the action in i.b) and i.c), arrange the pointer in the required
order (i.e which pointer should start and which should follow). Hints: Use
Figure 1. (0.5 Marks Each)
a. For i.b). ______________ b. For i.a). ______________
iii. For actions in i.a), i.b), and i.c); write one or two lines of codes to
accomplish the action (remember that the new node has already been created
and the place to join it has already been indicated). Hints: Use Figure 2.
(1 Mark Each)
a. For i.a). __________________________________________________
b. For i.b). __________________________________________________
c. For i.c). __________________________________________________
iv. Write the line(s) of code to add the new node if: (0.5 Marks Each)
a. Figure 2 is a queue _________________________________________
b. Figure 2 is a stack _________________________________________
v. If the structure name is List, write the structure definition for Linked List
shown in the figures. (1.5 Marks)
Structure definition here

2. Given that Figure 3 is a Linked List, and p, q, x, y are pointers to be used.

i. Write the line(s) of code to delete the last node _______________________


______________________________________________ (1 Marks)
ii. Write the line(s) of code to delete the third node ______________________
________________________________________________ (1 Marks)
iii. Write the line(s) of code to delete the first node ______________________
_________________________________________________ (1 Marks)
iv. Write the line(s) of code to delete one node if Figure 3 is: (0.5 Marks Each)
a. A stack _______________________________________________
__________________________________________________________
b. A queue _______________________________________________
__________________________________________________________
3. Given a structure Car with model (array of character) and color (string) as
members of structure. Use pointer operator to store data for an ist car. Hints: Use
ist as structure variable and istptr as the pointer. (3 Marks)

You might also like