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.
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
Related questions
Question
Need answers for Q2 but its related to Q1 thats what i included Q1 as well
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps with 2 images
Recommended textbooks for you
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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education