Monash University > CSSE > CSE1303 > Part A> Pracs > Prac A5

CSE1303 Computer Science
Semester 2, 2003
Part A
Prac A5 : Binary Search Trees

This prac covers material from lectures A11 to A13 and Tutorial A5.

Project

To write a program to find anagrams.

Background

An anagram of a word is a rearrangement of the letters in the word, in order to form a different word. For example tear, rate, and tare are all anagrams of each other - they all use the same letters, just in a different order.

In this practical session you will use a Binary Search Tree to implement a database for storing character strings. Then you will use this database in a program to find anagrams.


Preparation (3 marks if completed before class)

The marks for Preparation will be awarded only if the preparation is complete before the start of the class.


Question 1: (2 marks)


Question 2: (2 marks)

Write the following two C functions and a C program which demonstrates that the two functions work.

  1. char* doubleString(char* str) which creates a new character string which contains a copy of str followed by a space, followed by another copy of str concatenated together, and returns the address of the new string. For example, when given the string "spot" it return the address to the character string , "spot spot".

  2. void sortString(char* str, int size) which sorts the letters of the string, of length size, into alphabetical order using insertion sort. For example, when given the string "spot" and 4 as input, on return the string would be "opst"

    For question 3 you will need to sort the first part of the doubled string (for example, you would sort the first 4 characters of "spot spot" to get "opst spot"), so keep this in mind when you write your functions.


Question 3: (3 marks)


Advanced Questions: (2 marks)


[ Top | Home ]

Last modified: Thursday 26 June 2003 14:42:13