CSC 216/s08/no comparison: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 11: Line 11:
===Participants and props===
===Participants and props===


To run this exercise, you will need a class full of students and some paper and markers.
To run this exercise, you will need at least 6 students and some paper and writing utensils.  


===The script===
 
The instructor, or person leading the exercise will issue commands to the students. The first of these should be the creation of a node.
===How to Employ the Exercise===
 
Each student participating in the exercise has a card with "Data = [name]", name being the name of the student, written on it. One student is chosen to be the head of the list. Three students are then lined up to the left of the head of the list in alphabetical order. Starting from the head, each person will write "Next = [name of the person to their left]" on their card. This setup represents a basic linked list. Now we will practice inserting a new node. One of the remaining students will write "Data = [name]" on their card, and become the new node. The new node will ask if the first node is alphabetically before itself. If the answer is no, the new node will stand to the right of the first node. The new node will then write "Next = [name of the first node]" on his card. If the answer is yes, the new node will ask the next student in line until they receive a "no" answer or reach the end of the line. After the student has found their place in the line, they will write "Next = [name of the student to their left]". The student to the right of the new student will write "Next = [name of new student]" on their card. Now we will practice deleting a student. The instructor will choose a student to be deleted. Starting at the head of the list, he will ask each student if their "Data = [the chosen value]". If the answer is yes, the deleted student will pass the value of its "Next" to the student to their right. The student to their right will appropriately change their card, and the chosen student exits the list.

Revision as of 01:45, 16 April 2008

Formatting Resources

Formatting Help Guide from MetaWiki

Linked Lists in Person

This exercise will help students understand the structure of a linked list

The problem

A linked list is a useful data structure but it can be very confusing for students first trying to grasp it. This interactive exercise should help students understand the concept.

Participants and props

To run this exercise, you will need at least 6 students and some paper and writing utensils.


How to Employ the Exercise

Each student participating in the exercise has a card with "Data = [name]", name being the name of the student, written on it. One student is chosen to be the head of the list. Three students are then lined up to the left of the head of the list in alphabetical order. Starting from the head, each person will write "Next = [name of the person to their left]" on their card. This setup represents a basic linked list. Now we will practice inserting a new node. One of the remaining students will write "Data = [name]" on their card, and become the new node. The new node will ask if the first node is alphabetically before itself. If the answer is no, the new node will stand to the right of the first node. The new node will then write "Next = [name of the first node]" on his card. If the answer is yes, the new node will ask the next student in line until they receive a "no" answer or reach the end of the line. After the student has found their place in the line, they will write "Next = [name of the student to their left]". The student to the right of the new student will write "Next = [name of new student]" on their card. Now we will practice deleting a student. The instructor will choose a student to be deleted. Starting at the head of the list, he will ask each student if their "Data = [the chosen value]". If the answer is yes, the deleted student will pass the value of its "Next" to the student to their right. The student to their right will appropriately change their card, and the chosen student exits the list.