Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

CS Diagnostic Exam: Algorithm Questions for CS 600, Fall 2002, Assignments of Computer Science

A cs diagnostic exam from the fall 2002 semester for the algorithm (cs 600) course. It includes two parts, each with several questions related to algorithms for detecting zero bits or consecutive zero bits in a hardware register, and detecting consecutive zeros in a string of length n. The basic operations available on a hardware register and asks for efficient algorithms to solve the given problems.

Typology: Assignments

2019/2020

Uploaded on 11/25/2020

koofers-user-wv3
koofers-user-wv3 🇺🇸

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Fall 2002 ALG: Page 1 of 1
QUESTION CODE: ALG
CS Diagnostic Exam
Fall 2002
Algorithm (CS 600)
Part I
Consider a hardware register inside a CPU. Operations available on
this register are common machine-level operations:
- load and store register contents from memory
- rotate with wrap around register contents 1 bit left (or right)
- arithmetic between the register and either memory locations
or constant values
- bitwise logical operations between the register and either
memory locations or constant values
- jump (to an address) if the sign bit is set,
- jump (to an address) if the register is zero
a) Give an algorithm to efficiently determine if any single bit in the
register is zero (ie is it false that the register has all ones).
b) Give an algorithm to efficiently determine if any two consecutive bits in
the register are zero.
c) Give an algorithm to efficiently determine if any three consecutive bits
in the register are zero. Generalize this procedure to detecting k
consecutive zero bits?
(Note that for the purpose of efficiency all of the operations are considered
as taking the same amount of time. Thus a load operation takes the same
amount of time as a rotate.)
Part II
a. Consider the problem of determining if a string of length n has two
consecutive zeros. The basic operation is to examine a position in the
string to see if it is a 0 or a 1. For each n =2,3,4,5 either give an
adversary strategy to force any algorithm to examine every bit, or give an
algorithm that solves the problem by examining less than n bits.
b. Give a general solution for n = 3k + 1 for k >= 2.

Partial preview of the text

Download CS Diagnostic Exam: Algorithm Questions for CS 600, Fall 2002 and more Assignments Computer Science in PDF only on Docsity!

Fall 2002 ALG: Page 1 of 1

QUESTION CODE: ALG

CS Diagnostic Exam

Fall 2002

Algorithm (CS 600)

Part I Consider a hardware register inside a CPU. Operations available on this register are common machine-level operations:

  • load and store register contents from memory
  • rotate with wrap around register contents 1 bit left (or right)
  • arithmetic between the register and either memory locations or constant values
  • bitwise logical operations between the register and either memory locations or constant values
  • jump (to an address) if the sign bit is set,
  • jump (to an address) if the register is zero a) Give an algorithm to efficiently determine if any single bit in the register is zero (ie is it false that the register has all ones). b) Give an algorithm to efficiently determine if any two consecutive bits in the register are zero. c) Give an algorithm to efficiently determine if any three consecutive bits in the register are zero. Generalize this procedure to detecting k consecutive zero bits? (Note that for the purpose of efficiency all of the operations are considered as taking the same amount of time. Thus a load operation takes the same amount of time as a rotate.) Part II a. Consider the problem of determining if a string of length n has two consecutive zeros. The basic operation is to examine a position in the string to see if it is a 0 or a 1. For each n =2,3,4,5 either give an adversary strategy to force any algorithm to examine every bit, or give an algorithm that solves the problem by examining less than n bits. b. Give a general solution for n = 3k + 1 for k >= 2.