You are on page 1of 2

Assignment -1

Date: 02/08/2021 Deadline:02/08/2021 (7 pm)

Consider there are n (take input value of n from user) students. Read name of
the students from user and store the name of the students in an array. String
library may be used.
a. Check if any name in input is not unique then you should print an error
message. Now create a linked list where each node of that linked list will
contain shortest prefix of student’s name which unambiguously
distinguishes students. Sort the prefixes of the linked list in dictionary order
(Array content should not be disturbed). Go through sorted linked list and
print full name. Example: Names in array:: Aloke, Anirudh, Anirban, Aniket,
Animesh, Hridesh Initial prefixes in the listAl, Aniru, Anirb, Anik, Anim, H
 After sorting prefixes in list  Al, Anik, Anim, Anirb, Aniru, H  Final
names to be printed :: Aloke, Aniket, Animesh, Anirban, Anirudh, Hridesh
[12]

Input:
6 (number of persons)
Aloke, Anirudh, Anirban, Aniket, Animesh, Hridesh (name of persons)

Output1: Al, Aniru, Anirb, Anik, Anim, H (After inserting prefixes in linked list)
Output2: Al,Anik,Anim,Anirb,Aniru,H (After sorting list as per dictionary order)
Output3: Aloke, Aniket, Animesh, Anirban, Anirudh, Hridesh

Upload : 1a.c

b. Create two single linked list of nearby equal size (x=n/2 and y=n-n/2) where
first list will have details of first x students and second list will have details of
last y students. Each node of the list will contain only the first letter of the
name. Now arrange each linked list in such a way that node with vowels
comes before node with consonant. However, you have to make sure that
nodes with vowels maintain their order among themselves as per arrival
(entry order from user) and similarly nodes with consonants also maintain
their order. Comment if any of these two linked list or any sublist (part of the
list having more than two elements) are palindrome. Example: Michael,
Alexander, Ethan, Jacob, Mason, Firoz, Noah, Liam, Poli, Samuel, Noman,
Alle [8]
Linked List: M-> A-> E-> J->M->F and N->L->P->S->N->A Arranged linked
list A->E->M->J->M->F and A->N->L->P->S->N, M->J->M is a palindrome.

Input: Michael, Alexander, Ethan, Jacob, Mason, Firoz, Noah, Liam, Poli,
Samuel, Noman, Alle
Output1: M-> A-> E-> J->M->F
N->L->P->S->N->A
Output2: A->E->M->J->M->F
A->N->L->P->S->N
Output3: List 1 has following palindrome(s)
M->J->M
List 2 does not have any palindrome

Upload : 1b.c

You might also like