Algorithms and data structures, Assignments of Computer Science

Assignments and notes on Algorithms

Typology: Assignments

2024/2025

Uploaded on 06/01/2025

ashraf-chongolo
ashraf-chongolo 🇲🇼

3 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
UU-COM 2012
Data Structures and Algorithms
Page 1
UU-COM 2012 Data Structures and Algorithms
Assignment 1
Questions
1. Describe the algorithm used by your favorite ATM machine in dispensing cash. (You may give your
description in either English or pseudocode, whichever you find more convenient.)
2. There are four people who want to cross a rickety bridge; they all begin on the same side. You have
17 minutes to get them all across to the other side. It is night, and they have one flashlight. A
maximum of two people can cross the bridge at one time. Any party that crosses, either one or two
people, must have the flashlight with them. The flashlight must be walked back and forth; it cannot
be thrown, for example. Person 1 takes 1 minute to cross the bridge, person 2 takes 2 minutes, person
3 takes 5 minutes, and person 4 takes 10 minutes. A pair must walk together at the rate of the slower
person’s pace.
3. Research perfect hash functions. Using a list of names (classmates, family members, etc.), generate
the hash values using the perfect hash algorithm.

Partial preview of the text

Download Algorithms and data structures and more Assignments Computer Science in PDF only on Docsity!

UU-COM 2012

Data Structures and Algorithms

UU-COM – 2012 Data Structures and Algorithms Page 1

Assignment 1

Questions

  1. Describe the algorithm used by your favorite ATM machine in dispensing cash. (You may give your description in either English or pseudocode, whichever you find more convenient.)
  2. There are four people who want to cross a rickety bridge; they all begin on the same side. You have 17 minutes to get them all across to the other side. It is night, and they have one flashlight. A maximum of two people can cross the bridge at one time. Any party that crosses, either one or two people, must have the flashlight with them. The flashlight must be walked back and forth; it cannot be thrown, for example. Person 1 takes 1 minute to cross the bridge, person 2 takes 2 minutes, person 3 takes 5 minutes, and person 4 takes 10 minutes. A pair must walk together at the rate of the slower person’s pace.
  3. Research perfect hash functions. Using a list of names (classmates, family members, etc.), generate the hash values using the perfect hash algorithm.