with reference to the images attached, draw a flow chart (with sub algorithm flowchart) for: Given a 1D array of 100 numbers, count the number of prime elements. the question is under javascript computational thinking thank you.
with reference to the images attached, draw a flow chart (with sub algorithm flowchart) for: Given a 1D array of 100 numbers, count the number of prime elements. the question is under javascript computational thinking thank you.
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
with reference to the images attached, draw a flow chart (with sub
Given a 1D array of 100 numbers, count the number of prime elements.
the question is under javascript computational thinking
thank you.
![Advanced Example 5
start
sum 0
i← 1
i ← i + 1
i≤ 100
T
sum sum+ a[i]
"sum = ", sum
end
Devise a program to
output sum of values
stored in an array of
100 elements
precondition: a, e R, 1 ≤ i ≤ 100
postcondition: a₁is outputted
100](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F1a310ed2-3377-4dab-b1a9-29fbcd4a5ef4%2Fa36b8455-a462-4a90-9434-be886ac3285a%2F1acgu4c_processed.png&w=3840&q=75)
Transcribed Image Text:Advanced Example 5
start
sum 0
i← 1
i ← i + 1
i≤ 100
T
sum sum+ a[i]
"sum = ", sum
end
Devise a program to
output sum of values
stored in an array of
100 elements
precondition: a, e R, 1 ≤ i ≤ 100
postcondition: a₁is outputted
100

Transcribed Image Text:Advanced Example 10
Devise a program to receive
a positive number, and print
all prime numbers less than
or equal to that number
We are going to reuse our solution to
Advanced Example 4 (to check if a
number is prime or not). we need to
modify it a bit to return a True or False
answer though.
York University EECS 1012F2023
...continued
This is called sub-algorithm
A sub-algorithm is called from
other algorithms
We called the prime sub-
algorithm from inside our AE10
When tracing an algorithm, we
normally treat sub-algorithms
as a black box (and we assume
they are correct)
precondition: num = N
postcondition: output all prime
numbers ≤ num
Exercise: trace advanced
example 10, for when input is 8
York University EECS 1012 F2023
14-2
start
num
1<--1+1
prime(/) = true
T
end
is num
Comp. Thinking (pt 3: Verification) 23
precondition: num>1 € N
postcondition: returns true if
num is prime, otherwise
returns false.
prime(num)
start
flag-true
d←2
flag true and
dsnum/2
num mod d=0
flag-false
d+d+1
F
ret flag
Comp. Thinking (pt 3: Verification) 24
F
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 3 steps with 2 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.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