Lab Test 1
Part 1 [Maximum marks: 30]
A binary tree is supplied in the data file against your name. Read the file, and create the tree in the standard pointer-based repreentation. Maintain links for left and right chlidren. Don't maintain parent links. In the first line of the file, the number of nodes is supplied. If this number is n, nodes in the tree are identified as 0,1,2,...,n - 1. For each node, its ID and the IDs of its two child nodes are supplied in the file (-1 indicates no child, that is, NULL). While creating the tree, you also need to identify the root of the tree (it is not the node with ID 0). Return a pointer to the root node. In all of the subsequent parts, this pointer should be passed as the tree, not the raw data from the file.
Hint: After you read n from the input file, allocate a dynamic array of n tree nodes. Then, read the input file, and create child connections. The unique node which is not the child of any other node is the root node. However, if you are more comfortable with the conventional recursive way of creating the binary tree, store the data from the file in some array(s).
Redirecting a file to your program
Part 2 [Maximum marks: 30]
Print all the leaves of the tree.
Part 3 [Maximum marks: 20]
Students with odd PC numbers: Determine the maximum level in the tree at which a leaf appears.
Students with even PC numbers: Determine the minimum level in the tree at which a leaf appears.
The root is assumed to be at level zero, its children at level 1, and so on.
Part 4 [Maximum marks: 20]
Students with odd PC numbers: Print all the leaf nodes at the maximum level.
Students with even PC numbers: Print all the leaf nodes at the minimum level.
Submission site
You must submit your C/C++ source file, and the output of your program on your input file given below.
Input and output files
- 07NA3014 Chandrakant Bharti [Output]
- 08CS3027 Shyam Kumar Murmu [Output]
- 08MA2024 Rachit Murarka [Output]
- 08ME1006 Suvodhoy Sinha [Output]
- 09CS1044 Putty Vikas [Output]
- 09CS1046 Mood Vamshi Krishna Naik [Output]
- 09CS3031 Balaga Prasanth [Output]
- 09CS3034 Rahul [Output]
- 09CY2007 Rajul [Output]
- 09EC1024 Arijit Layek [Output]
- 09EC3022 Amit Kumar [Output]
- 09IE1029 Prashant Kumar Singh [Output]
- 09ME1059 Siddharth S Bhandari [Output]
- 09ME3030 Prateek Anand [Output]
- 10CH10030 Pranjal Goswami [Output]
- 10CS10001 Aakaash Panigrahi [Output]
- 10CS10002 Aayush Sureka [Output]
- 10CS10003 Akhil Israni [Output]
- 10CS10004 Animesh Sinha [Output]
- 10CS10005 Anish Haldiya [Output]
- 10CS10006 Anjani Kumar [Output]
- 10CS10007 Ankit Khedia [Output]
- 10CS10008 Apoorv Raj [Output]
- 10CS10009 B Sai Krishna [Output]
- 10CS10010 Banavath Aditya Naik [Output]
- 10CS10011 Deepak Khaneja [Output]
- 10CS10012 E V V Devi Sandeep [Output]
- 10CS10013 Gadde Ravi Teja [Output]
- 10CS10014 Gokul Chand Meena [Output]
- 10CS10015 Jilla Vivek [Output]
- 10CS10016 K Sai Sreemukh [Output]
- 10CS10017 Kanwar Pal Dhande [Output]
- 10CS10018 Kaushik Kumar Mahato [Output]
- 10CS10019 Lava Kumar Bokam [Output]
- 10CS10020 Malay Pramanick [Output]
- 10CS10021 Mandeep Singh Gill [Output]
- 10CS10022 Manish Mittal [Output]
- 10CS10023 Milind Mandlik [Output]
- 10CS10024 Mohammad Salman [Output]
- 10CS10025 Nadeem Anjum [Output]
- 10CS10026 Naval Kishore Peepliwal [Output]
- 10CS10027 Navgeet Agrawal [Output]
- 10CS10028 Nerella Venkata Sravan Kishan [Output]
- 10CS10029 Nishant Dalmia [Output]
- 10CS10030 Padamata Mruthyunjaya Rao [Output]
- 10CS10031 Palash Goyal [Output]
- 10CS10032 Pilaka Sireesha [Output]
- 10CS10033 Ponkishore B [Output]
- 10CS10034 Potharaju Sri Vidya Pranavi [Output]
- 10CS10035 Ravella Chaitanya Sreenivas [Output]
- 10CS10036 Rohit Kumar [Output]
- 10CS10037 Ronak Kumar Heliwal [Output]
- 10CS10038 Sahil Sharma [Output]
- 10CS10039 Sandeep Kumar Sahu [Output]
- 10CS10040 Shabahat Shakeel [Output]
- 10CS10041 Shashwat Kumar [Output]
- 10CS10042 Shivangi Agarwal [Output]
- 10CS10043 Srikar Polipalli [Output]
- 10CS10044 Suhansanu Kumar [Output]
- 10CS10045 Sumit Kumar [Output]
- 10CS10046 Sumit Saurabh [Output]
- 10CS10047 Suraj Kumar [Output]
- 10CS10048 Sushovan Mandal [Output]
- 10CS10049 Swetha Tibrewal [Output]
- 10CS10050 Tadishetti Ramteja [Output]
- 10CS10051 Tauseef Nomani [Output]
- 10CS10052 Vadlamudi Jaya Krishna [Output]
- 10CS10053 Vemula Rohith [Output]
- 10CS10054 Vipul Jain [Output]
- 10CS10055 Vyas Yogarshi Paritosh [Output]
- 10CS10056 Yelam Anil Kumar [Output]
- 10CS10057 Abhishek Panigrahy [Output]
- 10CS10058 Pujari Rajkumar [Output]
- 10CS10059 Saurabh Shukla [Output]
- 10CS10060 M Dastagiri Reddy [Output]
- 10CS10061 Himanshu Tiwari [Output]
- 10CS30001 Aakash Goenka [Output]
- 10CS30002 Abhishek [Output]
- 10CS30003 Abhishek Gupta [Output]
- 10CS30004 Akash Amat [Output]
- 10CS30005 Akash Maurya [Output]
- 10CS30006 Akash Shah [Output]
- 10CS30007 Amit Kumar Pandey [Output]
- 10CS30008 Arunender Singhh [Output]
- 10CS30009 Ashish Vasava [Output]
- 10CS30010 Ashwani Attri [Output]
- 10CS30011 Bathulwar Akash [Output]
- 10CS30012 Bhadreswar Ghuku [Output]
- 10CS30013 Buha Rajan Govindbhai [Output]
- 10CS30014 Challamalla Venkata Charan Teja [Output]
- 10CS30015 Chitukuri Architha [Output]
- 10CS30016 Degwekar Anand Dhananjai [Output]
- 10CS30017 Devender [Output]
- 10CS30018 Dewesh Agrawal [Output]
- 10CS30019 Gurman Bhalla [Output]
- 10CS30020 Harmanpreet Singh [Output]
- 10CS30021 Imran [Output]
- 10CS30022 Jeldi Ratan Rahul [Output]
- 10CS30023 Kale Aditya Ashok [Output]
- 10CS30024 Khade Nilesh Gajanan [Output]
- 10CS30025 Komal Agrawal [Output]
- 10CS30026 Kontham Rajesh [Output]
- 10CS30027 Krishna Kant Sijariya [Output]
- 10CS30028 Mohit Sharma [Output]
- 10CS30029 Om Misra [Output]
- 10CS30031 Parantap Sharma [Output]
- 10CS30032 Pratapa Srihari Vijayendra [Output]
- 10CS30033 Rahul Dewangan [Output]
- 10CS30034 Ritwik Yadav [Output]
- 10CS30035 Rohan Jain [Output]
- 10CS30036 Saurabh Agarwal [Output]
- 10CS30037 Shambhu Prasad [Output]
- 10CS30038 Shubhang Verma [Output]
- 10CS30039 Siddharth Kumar [Output]
- 10CS30040 Akhil Saxena [Output]
- 10CS30041 Pyreddy Mary Arpita [Output]
- 10CS30042 Saurabh Hota [Output]
- 10CS30043 Aakash Anuj [Output]
- 10CS30044 Yetesh Chaudhary [Output]
- 10EC10008 Avinash Ruchandani [Output]
- 10EC10058 Tippa Veera Venkata Satish [Output]
- 10EC30013 Baheti Priyanka Sushil [Output]
- 10EC30031 Shreeja Subrata Datta [Output]
- 99FB1331 Foolan Barik [Output]
Submission site