Geschreven door studenten die geslaagd zijn Direct beschikbaar na je betaling Online lezen of als PDF Verkeerd document? Gratis ruilen 4,6 TrustPilot
logo-home
Tentamen (uitwerkingen)

Homework Assignment 1 - Complexity and ADTs - ALL ANSWERS ARE CORRECT

Beoordeling
-
Verkocht
-
Pagina's
3
Cijfer
A+
Geüpload op
29-01-2023
Geschreven in
2022/2023

Homework Assignment 1 - Complexity and ADTs Q1 - Q4 are related to the ADT material. In the lecture, we talked about "outside the black box" and "inside the black box". The related discussion question will give you some practice with working "outside the black box". The assignment is intended to help you think about "inside the black box", by having you look at alternative representations. In Q1, you look at an alternative to binary. In Q2, you look at an where stuff might be stored as a consequence of a selected implementation. In Q3 and Q4, you look at an alternative data structures to leverage the fact that many locations in a standard array might always be empty. In Q6 and Q7 you look at how the time is affected by the underlying cost of the algorithm. Question 4 is extra credit. 1. Show how nonnegative numbers can be represented in an imaginary ternary computer using trits (0,1,2) instead of bits (0,1). Why don't we do things this way? Decimal Ternary 0 0 1 1 2 2 3 10 4 11 5 12 6 20 7 21 8 22 9 100 10 101 There are no nonnegative integers that can be represented using ternary notation and trits that cannot be represented using binary notation and bits. There are also no nonnegative integers that can be represented using bits that cannot be represented using trits. Why don’t we do things this way? Binary computers are more common than ternary computers because a computer is an electrical device whose components are capable of two states only - on or off. Since the computer’s memory is simply a group of switches that may be only on or off, any bit of information stored in the computer at any time must have one of two mutually exclusive values : 1 (on) or 0 (off). 2. If each element of an array RM,with 10 rows and 20 columns, stored in row major order, takes four bytes of space, where the first element of RM starts at 100, what is the address of RM[5][3] and RM[9][19]? Using the zero-based arrays common to current programming languages: RM[5][3] : 100 + (5 * 20 * 4) + (3 * 4) = 512 RM[9][19] : 100 + (9 * 20 * 4) + (19 * 4) = 896

Meer zien Lees minder
Instelling
Vak

Voorbeeld van de inhoud

Homework Assignment 1 - Complexity and ADTs

Q1 - Q4 are related to the ADT material. In the lecture, we talked about "outside the black box" and
"inside the black box". The related discussion question will give you some practice with working
"outside the black box". The assignment is intended to help you think about "inside the black box", by
having you look at alternative representations. In Q1, you look at an alternative to binary. In Q2, you
look at an where stuff might be stored as a consequence of a selected implementation. In Q3 and Q4,
you look at an alternative data structures to leverage the fact that many locations in a standard array
might always be empty. In Q6 and Q7 you look at how the time is affected by the underlying cost of the
algorithm. Question 4 is extra credit.

1. Show how nonnegative numbers can be represented in an imaginary ternary computer using trits
(0,1,2) instead of bits (0,1). Why don't we do things this way?


Decimal Ternary
0 0
1 1
2 2
3 10
4 11
5 12
6 20
7 21
8 22
9 100
10 101

There are no nonnegative integers that can be represented using ternary notation and trits that
cannot be represented using binary notation and bits. There are also no nonnegative integers that
can be represented using bits that cannot be represented using trits.

Why don’t we do things this way?

Binary computers are more common than ternary computers because a computer is an electrical
device whose components are capable of two states only - on or off. Since the computer’s memory is
simply a group of switches that may be only on or off, any bit of information stored in the computer at
any time must have one of two mutually exclusive values : 1 (on) or 0 (off).


2. If each element of an array RM,with 10 rows and 20 columns, stored in row major order, takes
four bytes of space, where the first element of RM starts at 100, what is the address of RM[5][3] and
RM[9][19]?

Using the zero-based arrays common to current programming languages: RM[5][3] :

100 + (5 * 20 * 4) + (3 * 4) = 512

RM[9][19] : 100 + (9 * 20 * 4) + (19 * 4) = 896

Geschreven voor

Vak

Documentinformatie

Geüpload op
29 januari 2023
Aantal pagina's
3
Geschreven in
2022/2023
Type
Tentamen (uitwerkingen)
Bevat
Vragen en antwoorden

Onderwerpen

$8.49
Krijg toegang tot het volledige document:

Verkeerd document? Gratis ruilen Binnen 14 dagen na aankoop en voor het downloaden kun je een ander document kiezen. Je kunt het bedrag gewoon opnieuw besteden.
Geschreven door studenten die geslaagd zijn
Direct beschikbaar na je betaling
Online lezen of als PDF

Maak kennis met de verkoper

Seller avatar
De reputatie van een verkoper is gebaseerd op het aantal documenten dat iemand tegen betaling verkocht heeft en de beoordelingen die voor die items ontvangen zijn. Er zijn drie niveau’s te onderscheiden: brons, zilver en goud. Hoe beter de reputatie, hoe meer de kwaliteit van zijn of haar werk te vertrouwen is.
ExamsConnoisseur Self
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
587
Lid sinds
3 jaar
Aantal volgers
344
Documenten
1492
Laatst verkocht
1 week geleden

4.2

68 beoordelingen

5
40
4
11
3
13
2
1
1
3

Recent door jou bekeken

Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo makkelijk kan het dus zijn.”

Alisha Student

Bezig met je bronvermelding?

Maak nauwkeurige citaten in APA, MLA en Harvard met onze gratis bronnengenerator.

Bezig met je bronvermelding?

Veelgestelde vragen