Question 2 a) Implement Merge Sort in Python. b) Consider the following sequence of integers: 6 4 9 10 2 8 1 3 7 5 Explain in your own words how Insertion Sort works. Write the sequence of integers after the first iteration of the Insertion Sort algorithm (sorting from smallest to largest). c) Give the average and worst case Big O complexity for (a) Merge Sort and (b) Insertion Sort. Question 1 a) Use pseudocode to describe an algorithm that counts the number of letters, digits and special characters in a string. Anything between 'a' or 'A' and 'z' or 'Z' is considered a letter, anything between 0 and 9 is considered a digit, while anything else is considered a special character. Input: a string s read from the keyboard, for example s = '3 beautiful days.' Output: letter count / = 13, digit count d = 1, special character count c = 3 For solving this task, consider the string to be an array of characters and do not use any predefined functions that would make this task trivial. b) Show an implementation of the algorithm designed in the language of your choice. You will not be penalised for small syntactical errors. c) Implement an algorithm in the language of choice that counts the occurrence of a digit in a number recursively. Input: a number n read from the keyboard, for example n = 30563323 a digit d the occurrences of which should be counted, for example d = 3 Output: a number c = 4 (i.e., how many of digit d there are in n). For solving this task, consider the string to be an array of characters. You can use any predefined functions in the language of your choice, however their name and number/location of arguments must be accurate.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Need answers for Q2 but its related to Q1 thats what i included Q1 as well 

Question 2
a) Implement Merge Sort in Python.
b) Consider the following sequence of integers: 6 4 9 10 2 8 1 3 7 5
Explain in your own words how Insertion Sort works. Write the sequence of integers after
the first iteration of the Insertion Sort algorithm (sorting from smallest to largest).
c) Give the average and worst case Big O complexity for (a) Merge Sort and (b) Insertion
Sort.
Transcribed Image Text:Question 2 a) Implement Merge Sort in Python. b) Consider the following sequence of integers: 6 4 9 10 2 8 1 3 7 5 Explain in your own words how Insertion Sort works. Write the sequence of integers after the first iteration of the Insertion Sort algorithm (sorting from smallest to largest). c) Give the average and worst case Big O complexity for (a) Merge Sort and (b) Insertion Sort.
Question 1
a) Use pseudocode to describe an algorithm that counts the number of letters, digits and
special characters in a string. Anything between 'a' or 'A' and 'z' or 'Z' is considered a
letter, anything between 0 and 9 is considered a digit, while anything else is considered a
special character.
Input: a string s read from the keyboard, for example s = '3 beautiful days.'
Output: letter count / = 13, digit count d = 1, special character count c = 3
For solving this task, consider the string to be an array of characters and do not use any
predefined functions that would make this task trivial.
b) Show an implementation of the algorithm designed in the language of your choice. You
will not be penalised for small syntactical errors.
c) Implement an algorithm in the language of choice that counts the occurrence of a digit in a
number recursively.
Input:
a number n read from the keyboard, for example n = 30563323
a digit d the occurrences of which should be counted, for example d = 3
Output: a number c = 4 (i.e., how many of digit d there are in n).
For solving this task, consider the string to be an array of characters. You can use any
predefined functions in the language of your choice, however their name and
number/location of arguments must be accurate.
Transcribed Image Text:Question 1 a) Use pseudocode to describe an algorithm that counts the number of letters, digits and special characters in a string. Anything between 'a' or 'A' and 'z' or 'Z' is considered a letter, anything between 0 and 9 is considered a digit, while anything else is considered a special character. Input: a string s read from the keyboard, for example s = '3 beautiful days.' Output: letter count / = 13, digit count d = 1, special character count c = 3 For solving this task, consider the string to be an array of characters and do not use any predefined functions that would make this task trivial. b) Show an implementation of the algorithm designed in the language of your choice. You will not be penalised for small syntactical errors. c) Implement an algorithm in the language of choice that counts the occurrence of a digit in a number recursively. Input: a number n read from the keyboard, for example n = 30563323 a digit d the occurrences of which should be counted, for example d = 3 Output: a number c = 4 (i.e., how many of digit d there are in n). For solving this task, consider the string to be an array of characters. You can use any predefined functions in the language of your choice, however their name and number/location of arguments must be accurate.
Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education