Assignment No 1
Assignment No 1
Asma Sattar
Section A
Problem 1
Write a program for a company where they need help to calculate the monthly wages of their
employees depending upon the number of hours they work in the organization. Your program should
be generic for any number of employees. Load the names and working hours of the employees from
“Employees.txt” file. Wage Criteria is: (50 x number of hours they’ve worked in a month)
At the end, show all the employee names and their wages on the screen an also save them in a file
namely “Wages.txt”.
Problem 2:
Note: Merge two sorted linked lists.
You’re given the pointer to the head nodes of two sorted linked lists. Change the next pointers to
obtain a single, merged linked list which also has data in ascending order. Input the link list data from
the user.
Problem 3:
Note: Use Single linked list.
Problem 4:
Note: analyse for time complexity. Big O
Write big O for each of the following code. Also write number of operations for mentioned values of
n
a. (3 points)
int main()
int n;
cin >> n;
int i = 1;
while (i <= n)
b. (3 points)
int main()
++alphabet;
return 0;
c. (4 points)
#include<iostream.h>
int main()
int a=1;
while(a<3)
cout<<"Cat"<<endl;
a=a+1;
int b=0;
while(b<2)
cout<<"Dog"<<endl;
b=b+1;
};
system("pause");
return 0;
};
Problem 5:
You have to take input from the file input.txt and do double linked list insertion on it. After that you
have to sort the nodes in a way that data on odd nodes should come first and data on even nodes
should be on end. For example 5->6->8->9->14->12->19 after sorting the result should be 6->9->12->5-
>8->14->19.(Note: There are multiple solution of this problem you must use efficient one and you
have to do sorting on nodes not on the data.)
Problem 6:
Write a code to Take Union And Intersection of three singly linked-list containing WORDS .
The final linked list should be sorted in ascending order according to first alphabet of WORD
The output should be proper.
Do the same task with doubly circular linked list
Problem 7:
Given a sorted doubly linked list of positive distinct elements, the task is to find pairs in the
doubly linked list whose product is equal to given value x, without using any extra space.
Problem 8:
Write a Program to check if the singly linked- list is palindrome .
If the linked list is not palindrome then sort the list in ascending and descending order .