Online Assignment 2
Online Assignment 2
Online Assignment 2
Duration: 1h
DL_head
2 3 11 7
NULL
NULL
Where DL_head is a pointer pointing to the first node of the double linked list. A structure of nodes of
double linked list as following:
struct doubleNode{
int data;
};
Please write a function to insert a node with data X at the end of double linked list. The format of this
function is:
For example
What is the content of the queue after the following sequence of pushes (or enqueue) and pops (or
dequeue):
Queue q; push( q,3 ); push( q,5 ); push( q,2 ); push( q,15 ); push( q,42 ); pop(q); pop(q); push( q,14 );
push( q,7 ); pop(); push( q,9 ); pop(q); pop(q); push( q,51 ); pop(q); pop(q);
Question 4 (2 points)
-int top_Queue (Queue Q): return an integer at head of the queue without deletion.
-void push (Stack S, int X): insert an integer at head of the stack
-void top_Stack (Stack S): return an integer at head of the stack without deletion
By only using queue and stack with their 8 basic functions, please write a C program to combine two
sorted queues Q1 and Q2 into one sorted queue Q3. Assuming that Q1 is already in increasing order, Q2
is already in decreasing order, and output Q3 should be in increasing order.
You don’t need to write codes for 8 basic functions. Assuming that they are already implemented.
Question 5 (2 points) A word is inversible if we reverse the letters of the word and we receive a same
word. For example, “hannah” is inversible because if we reverse this word, we also receive the
“hannah”. Given a word stored in a single linked list. Write an efficient algorithm in C language to check
if a word is inversible or not. Array is not allowed in the algorithm.