Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Case

Computational Thinking Assignment 4

Rating
-
Sold
-
Pages
7
Grade
9-10
Uploaded on
14-06-2022
Written in
2019/2020

Computational Thinking Assignment 4

Institution
Course

Content preview

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.

Written for

Institution
Study
Course

Document information

Uploaded on
June 14, 2022
Number of pages
7
Written in
2019/2020
Type
CASE
Professor(s)
Bhulai
Grade
9-10

Subjects

$7.25
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
TR19

Get to know the seller

Seller avatar
TR19 Vrije Universiteit Amsterdam
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
9 year
Number of followers
0
Documents
7
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions