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
Exam (elaborations)

Exam (elaborations) wgu c949

Rating
-
Sold
-
Pages
7
Grade
A+
Uploaded on
17-10-2024
Written in
2024/2025

WGU C949 Data Types STUDY GUIDE and answers ArrayA data structure that stores an ordered list of items, with each item is directly accessible by a positional index. Linked ListA data structure that stores ordered list of items in nodes, where each node stores data and has a pointer to the next node. Bianary Search TreeA data structure in which each node stores data and has up to two children, known as a left child and a right child. Hash TableA data structure that stores unordered items by mapping (or hashing) each item to a location in an array (or vector). Abstract Data Type (ADT)A data type described by predefined user operations, such as "insert data at rear," without indicating how each operation is implemented. ListAn ADT for holding ordered data. Dups ok Sequence type: A mutable container with ordered elements. Underlying data structures: Array, linked list Array in Javageneric class that supports different data types. declared as follows, where T is the data type. TupleSequence type: An immutable container with ordered elements. StackAn ADT in which items are only inserted on or removed from the top of a

Show more Read less
Institution
Wgu C949
Course
Wgu c949

Content preview

WGU C949 - Searching and Sorting
Algorithms answers
Binary search✔✔A faster algorithm for searching a list if the list's elements are
sorted and directly accessible (such as an array). Binary search first checks the
middle element of the list. If the search key is found, the algorithm returns the
matching location. If the search key is not found, the algorithm repeats the search on
the remaining left sublist (if the search key was less than the middle element) or the
remaining right sublist (if the search key was greater than the middle element).

Binary search efficiency✔✔For an N element list, the maximum number of steps
required to reduce the search space to an empty sublist is [ log2 N ] + 1

Selection sort✔✔Sorting algorithm that treats the input as two parts, a sorted part
and an unsorted part, and repeatedly selects the proper next value to move from the
unsorted part to the end of the sorted part.

Selection sort efficiency✔✔If a list has N elements, the outer loop executes N times.
For each of those N outer loop executions, the inner loop executes an average of
N/2 times. So the total number of comparisons is proportional to N * (N/2), or O(N^2)

Selection sort (python)✔✔# replace "^\.+" with space
def SelectionSort(numbers):
....for idx in range(len(numbers)):
........min_idx = idx
........for comp in range(idx+1, len(numbers)):
............if numbers[min_idx] > numbers[comp]:
................min_idx = comp
........temp = numbers[idx]
........numbers[idx] = numbers[min_idx]
........numbers[min_idx] = temp
if __name__ == "__main__":
....numlist = [ 99, 77, 33, 55, 11 ]
....print("Before: " + str(numlist))
....SelectionSort(numlist)
....print("After: " + str(numlist))

Binary search (python)✔✔# replace "^\.+" with space
def BinarySearch(num, numbers):
....low = 0
....high = len(numbers) - 1
....mid = 0
....while low <= high:
........mid = (high + low) // 2
........if numbers[mid] < num:
............low = mid + 1
........elif numbers[mid] > num:
............high = mid - 1

, ........else:
............return mid
....return -1
if __name__ == "__main__":
....numlist = [ 11, 33, 55, 77, 99 ]
....for val in (11, 22, 55, 88, 99):
........print(f"Index of {val}: {BinarySearch(val, numlist)}")

Insertion sort✔✔The list is split into a sorted half and unsorted half. Values from the
unsorted part are picked and placed at the correct position in the sorted part (left) by
shifting all the elements towards the right (unsorted portion).

Insertion sort efficiency✔✔Time complexity of O(n*2)

Insertion sort (python)✔✔# replace "^\.+" with space
def InsertionSort(numbers):
....for idx in range(1, len(numbers)):
........val = numbers[idx]
........comp = idx-1
........while comp >=0 and val < numbers[comp]:
............numbers[comp+1] = numbers[comp]
............comp -= 1
........numbers[comp+1] = val
if __name__ == "__main__":
....numlist = [ 99, 77, 33, 55, 11 ]
....print("Before: " + str(numlist))
....InsertionSort(numlist)
....print("After: " + str(numlist))

Shell sort✔✔Sorting algorithm that splits the input list into a number of lists based on
the gap value. The number of interleaved lists is equal to the gap value and the
value of interleave_a[0] = input_list[0], interleave_b[0] = input_list[gap value],
interleave_c[0] = input_list[gap value * 2] and so on. The interleaved lists are
individually insertion sorted, merged and insertion sorted to get the final sorted list.

Shell sort efficiency✔✔Worst case efficiency is O(N^2), best case is O(N*log N)

Shell sort (python)✔✔# replace "^\.+" with space
def ShellSort(numbers):
....gap = len(numbers) // 2
....while gap > 0:
........for idx in range(gap, len(numbers)):
............temp = numbers[idx]
............comp = idx
............while comp >= gap and numbers[comp - gap] > temp:
................numbers[comp] = numbers[comp - gap]
................comp = comp - gap
............numbers[comp] = temp
........gap = gap // 2

Written for

Institution
Wgu c949
Course
Wgu c949

Document information

Uploaded on
October 17, 2024
Number of pages
7
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

$8.49
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
ExamZen

Also available in package deal

Thumbnail
Package deal
C949 WGU questions and answers PACKAGE
-
5 2024
$ 30.97 More info

Get to know the seller

Seller avatar
ExamZen Liberty University
View profile
Follow You need to be logged in order to follow users or courses
Sold
16
Member since
1 year
Number of followers
3
Documents
539
Last sold
1 month ago

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