Prog Tutorial3 PDF
Prog Tutorial3 PDF
2. Create a library system that stores the books available as a doubly linked list.
Create a class Book, which contains at least two data members: title and author. (Assume
only one author)
Create two types of linked lists: the first one will sort according to title, and the second one
will sort according to author.
Write a main function to demonstrate the linked list.
Note: create the necessary function to insert and remove book.
KIE1008 (Programming Tutorial) Session 2016/2017 (Semester 2)
3. In a game, all the players are lined up after the other and assigned a number: the first person is 1,
the second is 2 and so on until N.
Starting from the first player, every 4th person in the line will be eliminated.
When the counting reach the end of the line, it is then continued from the beginning again. The
last player survive the elimination is the winner of the games.
For example, if there are 6 players:
123456 -> 3 is first eliminated, followed by 6.
1245 -> 4 is eliminated
125 -> 2 is eliminated
15-> 5 is eliminated
1 is the winner.
Write a program that creates a circular linked list of nodes to determine which position will win if
there are N players in the game (take N from 2 to 50).
Your program should simulate the elimination process by showing the elimination sequence for
each case. Consider also the possibility of deleting the head node in the list. Example output:
For N = 6, elimination sequence: 3, 6, 4, 2, 5, 1 (winner)
Note: modify the code to eliminate every x-th person, and display a table for N from 2 to 50, and
x from 2 to 10, that shows the winner for each case.
--END--