For Bilkent CS201 Midterm and Final - Worksheet PDF

Title For Bilkent CS201 Midterm and Final - Worksheet
Author Mustafa Culban
Pages 5
File Size 45.4 KB
File Type PDF
Total Downloads 431
Total Views 632

Summary

201 Work for Midterm You need to satisfy at leats 60 over 100 to pass the course. So get these fucking questions be solved. 1- Question is about singly circular linked list with no dumy node. class myList{ public: myList(); //tail pointer assigning to NULL void appendList(myList &other); private...


Description

201 Work for Midterm You need to satisfy at leats 60 over 100 to pass the course. So get these fucking questions be solved. 1- Question is about singly circular linked list with no dumy node. class myList{ public: myList(); //tail pointer assigning to NULL void appendList(myList &other); private: struct Node { int item; Node* next; }; Node* tail; };

Write appendList function that appands the input list given as parameter at the end of the list object calling this member fuction. For example if your first list contains [1 2 3 4] form start to end and your appending list contains [5 6 7 8] , your final list will be [1 2 3 4 5 6 7 8]. Your method should be working on O(1) time. You cannot change or add any thing into myList class.

2- A- In this problem a sorted linked list is given to you as in ascending order. struct Node { int item; Node* next; }; class SortedList{ public: SortedList(){ head = NULL; } Node *head; };



Write a global function which takes head pointer of a list and an integer value as input and returns the adress of Node after which the given value should be inserted. This function wont do and insertian at all. You dont do an insertion. It just returns the adress. For example,fort he linked list below, your function should return the adress of the node that contains an integer value of 7 if the input value is 9. Your function should return NULL if the input value is 1. 3 à 7 à 11 à 13

Fill the prototype of the function below and solve it. _________ findAdress( ________ head, const int value){ } B-



2

struct DoublyList { int item; DoublyList *next; DoublyList *prev; };

Consider that doubly linked list implementation. You need to write code segment which inserts new node pointed by newPtr after the node pointed by cur. (Assume cur pointer will not hold NULL value.)

3- Express the output of these functions seperately. class Test{ public: Test(int no = 0){ id = no; cout...


Similar Free PDFs