
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
![A1.1.6 (a) create the recursive function BinaryGCd (a,b) based on the following pseudo code
# recursive pseudo-code
def BinaryGCF (a,b):
arrange order so ab
if a=0:
if a and b are even:
else if a is even:
else if b is even:
else:
done, b is GCF
GCF (a,b) = 2*GCF (a/2, b/2)
GCF (a,b) = GCF (a/2, b)
GCF (a,b)
GCF (a,b)
In [ ]: def BinaryGCF (a,b):
GCF (a,b/2)
GCF (a,b-a)
(b) demonstrate that it gives the same results as pfGCD (a,b) and EuclidGCD (a, b) from A1.5.
"enter the recursive code below"
for a,b in [(660,350), (99,53), (30,84)]:
# demonstrate all GCD functions give the same result
13](https://content.bartleby.com/qna-images/question/96eb680b-bf96-4b4b-a2da-be1777b93ea0/d8706c35-0dbc-4bf8-9400-62922349013f/utp2ac_thumbnail.png)
Transcribed Image Text:A1.1.6 (a) create the recursive function BinaryGCd (a,b) based on the following pseudo code
# recursive pseudo-code
def BinaryGCF (a,b):
arrange order so ab
if a=0:
if a and b are even:
else if a is even:
else if b is even:
else:
done, b is GCF
GCF (a,b) = 2*GCF (a/2, b/2)
GCF (a,b) = GCF (a/2, b)
GCF (a,b)
GCF (a,b)
In [ ]: def BinaryGCF (a,b):
GCF (a,b/2)
GCF (a,b-a)
(b) demonstrate that it gives the same results as pfGCD (a,b) and EuclidGCD (a, b) from A1.5.
"enter the recursive code below"
for a,b in [(660,350), (99,53), (30,84)]:
# demonstrate all GCD functions give the same result
13
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 8 steps with 5 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.Similar questions
- PLEASE TYPE ONLY*** Exercise 5.3.1: Counting passwords without repeating characters. Consider the following definitions for sets of characters: Digits = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 } Letters = { a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z } Special characters = { *, &, $, # } Compute the number of passwords that satisfy the given constraints. (a) Strings of length 6. Characters can be special characters, digits, or letters, with no repeated characters. (b) Strings of length 6. Characters can be special characters, digits, or letters, with no repeated characters. The first character can not be a special character.arrow_forward#9arrow_forward11.10 LAB: All permutations of names C++ Write a program that lists all ways people can line up for a photo (all permutations of a list of strings). The program will read a list of one word names (until -1), and use a recursive method to create and output all possible orderings of those names, one ordering per line. When the input is: Julia Lucas Mia -1 then the output is (must match the below ordering): Julia Lucas Mia Julia Mia Lucas Lucas Julia Mia Lucas Mia Julia Mia Julia Lucas Mia Lucas Julia Please help with //TODO #include <vector>#include <string>#include <iostream> using namespace std; // TODO: Write method to create and output all permutations of the list of names.void AllPermutations(const vector<string> &permList, const vector<string> &nameList) { } int main(int argc, char* argv[]) {vector<string> nameList;vector<string> permList;string name; // TODO: Read in a list of names; stop when -1 is read. Then call…arrow_forward
- 5.2 Write a function in Javascript to take input a matrix as a parameter and returns whether the matrix is a diagonal matrix or not. Note: In the diagonal matrix only the elements of the main diagonal are non-zero, rest all elements are zero.arrow_forward10.4 python language Write a function median() with a variable number of arguments that can return the median value of the arguments. • Median is the "middle" of a sorted list of numbers.arrow_forwardLAB 20.14.1: LAB: Count characters 0/10 АCTIVITY LabProgram.java 1 import java.util.Scanner; 3 public class LabProgram { 4 public static void main(String[] args) { /* Туре уоиr code here. */ } 5 6 7 } 8.arrow_forward
- 3. Sorting 3.1. Understand the soring processes/steps for Bubble/ Selection/Insertion sort 3.2. Please fill in each blank with a proper code 1 2 3 6 7 8 9 10 11 12 13 /** Insertion-sort of an array of characters into nondecreasing order */ public static void insertionSort(char[] data) { int n = data.length; for (int k = 1; karrow_forwardmatrixA = []matrixB = []matrixC = [] I need help creating a phython codearrow_forward6.9 LAB: All permutations of names Write a program that lists all ways people can line up for a photo (all permutations of a list of Strings). The program will read a list of one word names (until -1), and use a recursive method to create and output all possible orderings of those names, one ordering per line. When the input is: Julia Lucas Mia -1 then the output is (must match the below ordering): Julia Lucas Mia Julia Mia Lucas Lucas Julia Mia Lucas Mia Julia Mia Julia Lucas Mia Lucas Julia import java.util.Scanner;import java.util.ArrayList; public class PhotoLineups { // TODO: Write method to create and output all permutations of the list of names.public static void allPermutations(ArrayList<String> permList, ArrayList<String> nameList) {} public static void main(String[] args) {Scanner scnr = new Scanner(System.in);ArrayList<String> nameList = new ArrayList<String>();ArrayList<String> permList = new ArrayList<String>();String name;//…arrow_forward
- 13.3 LAB: Algorithm 2 Bubble Sort CORAL LANGUAGE PLEASE This zyLab is about Bubble Sort Algorithm.The first number is the size of the arrayThe rest of the numbers are the values of arrayexample 1:Input7 44 94 27 89 48 58 4Output4 27 44 48 58 89 94example 2:Input9 22 56 33 78 16 99 17 8 2Output2 8 16 17 22 33 56 78 99arrow_forward5.3 Simultaneous Equations III Write the following sets of simultaneous equations in matrix form and solve the new equations (if possible): 3x₁ + 1x2 + 5x3 a. 2x₁ + 3x2 − 1x3 b. C. = 6x₁ + 2x2 + 8x3 X₁ + 3x2 + 4x3 = -1x₁ + 4x₂ = = = 5x1 + 6x2 + 2x3 4y1 + 2y2 + Y3 + 5y4 3y₁ + y2 + 4y3 + 7y4 2y₁ + 3y2 + y3 + 6y4 3y1 + y2 + Y3 + 3y4 20, 5, 7. 14, 5, = 7. = = = = 52.9 74.2, 58.3, 34.2.arrow_forward4.6.1: Recursive function: Writing the base case. Add an if branch to complete double_pennies()'s base case.Sample output with inputs: 1 10Number of pennies after 10 days: 1024 Note: If the submitted code has an infinite loop, the system will stop running the code after a few seconds, and report "Program end never reached." The system doesn't print the test case that caused the reported message # Returns number of pennies if pennies are doubled num_days timesdef double_pennies(num_pennies, num_days):total_pennies = 0 ''' Your solution goes here ''' else:total_pennies = double_pennies((num_pennies * 2), (num_days - 1)) return total_pennies # Program computes pennies if you have 1 penny today,# 2 pennies after one day, 4 after two days, and so onstarting_pennies = int(input())user_days = int(input()) print('Number of pennies after', user_days, 'days: ', end="")print(double_pennies(starting_pennies, user_days))arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

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