100% tevredenheidsgarantie Direct beschikbaar na je betaling Lees online óf als PDF Geen vaste maandelijkse kosten 4.2 TrustPilot
logo-home
Case uitwerking

Computational Thinking Assignment 4

Beoordeling
-
Verkocht
-
Pagina's
7
Cijfer
9-10
Geüpload op
14-06-2022
Geschreven in
2019/2020

Computational Thinking Assignment 4










Oeps! We kunnen je document nu niet laden. Probeer het nog eens of neem contact op met support.

Documentinformatie

Geüpload op
14 juni 2022
Aantal pagina's
7
Geschreven in
2019/2020
Type
Case uitwerking
Docent(en)
Bhulai
Cijfer
9-10

Voorbeeld van de inhoud

Computational Thinking – Assignment 4 (Artificial Intelligence Year 1)


1. How to use merge sort?

Keys E X A M P L E
Index 0 1 2 3 4 5 6


The “Tree” below shows the merge sort for the list { E X A M P L E }. We can see that this list
is recursively divided into two halves, until the size of a particular part of the list is 1. Once this
happened for every single letter in this list, the merge sort will start. This algorithm starts
merging elements back, until the whole list is merged, in this case in alphabetic order. The last
step is merging the last two sorted halves.




2. Sort by Python

A. We need to sort the coordinates in ascending order by comparing the first part of the
coordinates. The coordinates are (f, 9), (z, 2), (t, 4), (x, 8), (b, 1), (m, 7).

Input =

, Computational Thinking – Assignment 4 (Artificial Intelligence Year 1)


Output =




As you can see, the first part of the coordinates, the letters, are now in ascending (=
alphabetic) order.

B. We need to sort the coordinates in ascending order by comparing the second part of the
coordinates. The coordinates are (f, 9), (z, 2), (t, 4), (x, 8), (b, 1), (m, 7).

Input =




Output =




As you can see, the second part of the coordinates, the numbers, are now in ascending order.

3. Sort and search

I.
Keys T F W C Q G P R O
Index 0 1 2 3 4 5 6 7 8
Unsorted list

A. First, we have to select one element from the list (this can be any element): the pivot. Let’s say we
select P from the list. Now we rearrange this list in such a way that all the elements lesser than or
equal to the P are towards the left of this pivot and all the elements greater than or greater than or
equal to the P are towards the right of this pivot. The list will look like this:

II. Keys F C G O P T W Q R
Index 0 1 2 3 4 5 6 7 8
Partitioned list

We call this whole process the “partitioning” of the list. The pivot is now in its final position in the sorted
array. Once we have partitioned the array like this (II. Partitioned list) all the elements smaller than the
pivot are to the left and all the elements greater than the pivot are to the right. We can break this
problem into two sub-problems: subproblem 1 and subproblem 2.
€5,49
Krijg toegang tot het volledige document:

100% tevredenheidsgarantie
Direct beschikbaar na je betaling
Lees online óf als PDF
Geen vaste maandelijkse kosten

Maak kennis met de verkoper
Seller avatar
TR19

Maak kennis met de verkoper

Seller avatar
TR19 Vrije Universiteit Amsterdam
Bekijk profiel
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
0
Lid sinds
9 jaar
Aantal volgers
0
Documenten
7
Laatst verkocht
-

0,0

0 beoordelingen

5
0
4
0
3
0
2
0
1
0

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

Veelgestelde vragen