lab1fall11 - CSE 2320 Lab Assignment 1 Due September 30,...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
CSE 2320 Lab Assignment 1 Due September 30, 2011 Goals: 1. Understanding of binary search. 2. Understanding of maps/permutations, indirection, and swapping. Requirements: 1. Write a C program to maintain n counters indexed by 0 .. n-1 . n will be the first input value and all counters are initially valued as zero. The following operations will then appear, one per line, in the input: a. 0 - terminate execution. b. 1 - print the counters in ascending index value order as ( index , count ) pairs. (O( n ) time) c. 2 - print the counters in ascending counter value order as ( index , count ) pairs. (O( n ) time) d. 3 i - add one to the counter indexed by i . (O(log n ) time) e. 4 i - subtract one from the counter indexed by i . (O(log n ) time) f. 5 i j - determine the number of counters whose values are no smaller than i and no larger than j . (O(log n ) time) The input will be read from standard input ( stdin ) as either keyboard typing or as a shell redirect ( < ) from a file. Prompts/menus are completely unnecessary!
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/25/2012 for the course CSE 2320 taught by Professor Bobweems during the Spring '12 term at UT Arlington.

Ask a homework question - tutors are online