Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

exam data structure for midterm, Exams of Data Structures and Algorithms

you should take a look and study

Typology: Exams

2019/2020

Uploaded on 11/18/2021

mohamad-zyoud
mohamad-zyoud 🇹🇷

1 document

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1/4
26.11.2020
ANKARA UNIVERSITY
COMPUTER ENGINEERING
COM2067/COM267 MIDTERM
180 m.
(Write answers of each question on same pdf file. Please submit only one file
in which all 3 answers are placed.)
pf3
pf4

Partial preview of the text

Download exam data structure for midterm and more Exams Data Structures and Algorithms in PDF only on Docsity!

ANKARA UNIVERSITY

COMPUTER ENGINEERING

COM2067/COM267 MIDTERM

180 m.

(Write answers of each question on same pdf file. Please submit only one file

in which all 3 answers are placed.)

1. (30 p) Explain briefly what the following functions that use the node structure below do. struct node { int data; struct node* next; }; (a) void function1(struct node** a, struct node** b) { struct node* cur; if (a == NULL) { a = b; } else { cur = a; while (cur - >next != NULL) { cur = cur - >next; } cur - >next = b; } b=NULL; } (b) static void function2(struct node head) { struct node r = NULL; struct node cur = head; struct node n; while (cur!= NULL) { n = cur - >next; cur - >next = r; r = cur; cur = n; } head = r; } (c) void function 3 (struct node head) { struct node cur = head; if (cur == NULL) return; while(cur - >next!=NULL) { if (cur - >data == cur - >next->data) { struct node nextNext = cur - >next->next; free(cur - >next); cur - >next = nextNext; } else { cur = cur - >next; } } }

3. (35 p) Define a node structure for the structure given below. struct node{ ... }; Write a complete C program that you will create the connections between nodes. You can assign, 1 to the value of the 1st element, 2 to the value of the 2nd element, n to the value if the nth element. Assume that the value n is user-entered in your program.