Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PART 1 Question 1 ( 4 0 marks ) You should be able to answer this question after you have studied up to Chapter 4

PART 1
Question 1(40 marks)
You should be able to answer this question after you have studied up to Chapter 4. For Q1(b), it may be helpful
to consult 6.4.1 as well.
This question tests the following learning outcomes:
Understand the common general-purpose data structures, algorithmic techniques and complexity classes.
Develop and apply algorithms and data structures to solve computational problems.
Analyse the complexity of algorithms to support software design choices.
Write readable, tested, documented and efficient Python code.
Q1(a)(6 marks)
In [1]:
%%javascript
var head=document.getElementsByTagName('head')[0],style = document.createElement('style'
The function definition below is taken from Chapter 4 and describes the general problem of finding the first
occurrence of a given character in a given string.
Function: first index \ Inputs: text, a string; character, a string \ Preconditions: |character|=1\ Output:
index, an integer \ Postconditions: if character occurs in text, index is the smallest integer such that
text[index]= character, otherwise index =|text|
Write a function defintion that finds the second occurrence of any vowel in a given string. If a second vowel
is not found, the function should indicate this by returning the length of the string. The vowels do not need
to be the same letter or the same case (i.e. uppercase or lowercase).
Examples: \ In the string 'Hello', the first occurrence of any vowel is 'e', the second occurrence of any vowel
is 'o', so the function would return 4.\ In the string 'Hi', there is no second occurence of any vowel, so the
function would return 2.
Q1(b)(8 marks)
Outline an algorithm in English which will implement the function you defined in question 1(a)
An outline in English should not be program code or pseudo-code; see Section 6.4.1 for further guidance on
outlining algorithms in English. Not using an English outline will lead to marks being deducted.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Security XI Status And Prospects

Authors: T.Y. Lin, Shelly Qian

1st Edition

0412820900, 978-0412820908

More Books

Students also viewed these Databases questions

Question

Define Management or What is Management?

Answered: 1 week ago

Question

What do you understand by MBO?

Answered: 1 week ago