Free Essay

Recursive

In: Computers and Technology

Submitted By KibblesNBits
Words 676
Pages 3
/*
* The application should be able to calculate factorials, bunny ears, nth number of fibonacci sequence,
* total number of blocks in a triangle, sum of digits (positive number), and occurence of specific
* number (7) in a positive number. I will make a menu to make a selection, and use recursion vs loops.
*/

import java.util.*; import java.util.InputMismatchException;

public class FunWithNumbersTestDrive
{
public static void main(String[] args) { Scanner input = new Scanner(System.in); // Scanner object for user input int choice, userNumber; // Integer for menu selection and another for integer to pass to methods long sevensAbound; // chose a larger primitive type for the howManySevens method to allow for more counting FunWithNumbers fun = new FunWithNumbers(); boolean done = false; try { do { fun.displayMenu(); choice = input.nextInt(); switch(choice) { case 1: System.out.print("Please enter the number that you would like to perform the factorial on: "); userNumber = input.nextInt(); System.out.println("The factoral of " + userNumber + " yields the value: " + fun.findFactorial(userNumber)); break; case 2: System.out.print("Please enter the number of fluffy bunnies whose ears you would like to count: "); userNumber = input.nextInt(); System.out.println(userNumber + " bunnies would get you " + fun.bunnyCounter(userNumber) + " ears."); break; case 3: System.out.print("Please enter the number representing the position in the Fibonacci Sequence " + "that you would like to see the value of: "); userNumber = input.nextInt(); System.out.println("The " + userNumber + " position in the Fibonacci Sequence is the value " + fun.fibonacciSequence(userNumber) + "."); break; case 4: System.out.print("Please enter the number of tiers in the triangle you would like to make: "); userNumber = input.nextInt(); System.out.println("Your triangle of " + userNumber + " height, would have " + fun.makeTriangle(userNumber) + " blocks in it."); break; case 5: System.out.print("Please enter the number whose individual digits you would like to sum: "); userNumber = input.nextInt(); System.out.println("The sum of the individual digits of the number " + userNumber + " is " + fun.addDigits(userNumber)); break; case 6: System.out.print("Plase enter the number that you would like to inspect for occurrences of 7: "); sevensAbound = input.nextLong(); System.out.println("In the number " + sevensAbound + ", there are " + fun.howManySevens(sevensAbound) + " occurrences of the number 7."); break; case 7: done = true; break; default: System.out.println("You have entered an incorrect selection, please try again! (1-7)"); } }while(!done); } catch(InputMismatchException e) { System.out.println("The input given was not numerical, aborting program"); } }
}

class FunWithNumbers
{
public static void displayMenu() { System.out.println("\nPlease make a selection from the following Menu:"); System.out.println("1. Find the factorial of a number."); System.out.println("2. Count the bunny ears of a given number of bunnies."); System.out.println("3. Determine the nth occurrence in the Fibonacci Sequence."); System.out.println("4. Figure the number of blocks to build a triangle of given number height."); System.out.println("5. Find the summation of the individual numbers that comprise a given number."); System.out.println("6. Count the occurrence of the number 7 in a given number."); System.out.println("7. Exit the Program."); } public static int findFactorial(int counter) // Takes in the number to be taken as factorial { if(counter == 1) { return 1; } else { return(counter * (findFactorial(counter - 1))); } } public static int bunnyCounter(int counter)// Takes in the number of bunnies, counts ears { if(counter == 0) { return 0; } else { return (2 + bunnyCounter(counter - 1)); } } public static int fibonacciSequence(int counter) // Delivers nth term of Fibonacci Sequence { if(counter == 0) { return 0; } else if(counter == 1) { return 1; } else { return(fibonacciSequence(counter - 2) + fibonacciSequence(counter - 1)); } } public static int makeTriangle(int counter) // Builds a triangle with base "counter", one less block per line { if(counter == 0) { return 0; } else { return(counter + makeTriangle(counter -1)); } } public static int addDigits(int number) // Sums the individual digits of the number passed { if(number == 0) { return 0; } else { return(number % 10 + addDigits(number / 10)); } } public static long howManySevens(long number) // Counts the occurrences of the number 7 in the given number { if(number == 0) { return 0; } else { long rightMostDigit = (number % 10); if(rightMostDigit == 7) { return(howManySevens(number / 10) + 1); } else { return(howManySevens(number / 10)); } } }
}…...

Similar Documents

Premium Essay

Monetary Policy

...both recursive and structural specifications, this study analyses the effects of interest rate, money growth and the movements in nominal exchange rate on real GDP growth and inflation in Sri Lanka for the period from 1978 to 2005. The results of the recursive VARs are broadly in line with the established empirical findings, especially when the interest rate is considered the monetary policy variable. Following a positive innovation in interest rate, GDP growth and inflation decrease while the exchange rate appreciates. When money growth and exchange rate are used as policy indicators, the impact on GDP growth contrasts with established findings. However, as expected, an exchange rate appreciation has an immediate impact on the reduction of inflation. Interest rate innovations are persistent, supporting the view that the monetary authority adjusts interest rates gradually, while innovations in money growth and exchange rate appreciation are not persistent. Several puzzling results emerge from the study: for most sub-samples, inflation does not decline following a contractionary policy shock; innovations to money growth raises the interest rate; when inflation does respond, it reacts to monetary innovations faster than GDP growth does; and exchange rate appreciations almost always lead to an increase in GDP growth. The results from the semi-structural VARs, which impose identification restrictions only on the policy block, are not different from those obtained from recursive......

Words: 18533 - Pages: 75

Premium Essay

Telecommunication Business

...Customer Benefits •  Referral Reward - RM120 per customer referred (one-time cash reward) •  Recursive Reward - 10% of monthly commitment from total preferred customers (up to RM10/customer) •  Appreciation Reward Life with free mobile ! How CRP Works Referrer You Life with free mobile ! Referral Reward Referral Reward You •  Direct referring – RM120/customer •  Earning more by referring more customers •  Expenses reduced become entirely FREE mobile services Life with free mobile ! Recursive Reward You After referring 4 customers ... 2 of your preferred customers will be randomly picked by the system to be moved up to your referrer. Both of them then become your Angel Customers. Life with free mobile ! Recursive Reward Referrer Your Angel Customers You “system move up” Life with free mobile ! Recursive Reward 1st Week You 1st week, you start with 2 preferred customers. Life with free mobile ! Recursive Reward 1st Week 2nd Week You 2nd week, your preferred customers increased to 6. Life with free mobile ! Recursive Reward 1st Week 2nd Week 3rd Week 3rd week, Your preferred customers You further increased to 14. Life with free mobile ! Recursive Reward Recursive Reward •  10% of the monthly commitment from total preferred customers (up to RM10/customer) •  Monthly recursive reward •  No sales target •  Personally refers 4 customers or more. Number of......

Words: 622 - Pages: 3

Free Essay

Data Structure

...algorithm must produce atleast one output as the result. c)Finiteness:The algorithm must terminate after a finite number of steps. d)Definiteness:The steps to be performed in the algorithm must be clear and unambiguous. e)Effectiveness:One must be able to perform the steps in the algorithm without applying any intelligence.           All algorithms basically fall under two broad categories-Iterative and Recursive algorithms.           Iterative Algorithms typically use loops and conditional statements.           Recursive Algorithms use a divide and Conquer strategy. As per this,the recursive algorithm breaks down a large problem into small pieces and then applies the algorithm to each of these smal pieces. Determining which algorithm is efficient than the other involves analysis of algorithms. While analyzing,time required to execute it determined .’time’ represents the number of operations that are carried out while executing the algorithm.           While analyzing iterative algorithms we need to determine how many times the loop is executed. To analyze a recursive algorithm one needs to determine amount of work done for three things: i.breaking down the large problem to smaller pieces. ii.Getting solution for each piece and combining the individual solutions to get the solution to the whole problem. iii.Combining this information and the number of the smaller pieces and their sizes,we then need to create a recurrence relation for the......

Words: 2466 - Pages: 10

Free Essay

Data Structures

...order of words in a sentence . . . . . . . . . . . 11.2 Detecting a palindrome . . . . . . . . . . . . . . . . . . . . . 11.3 Counting the number of words in a string . . . . . . . . . . . 11.4 Determining the number of repeated words within a string . . 11.5 Determining the first matching character between two strings 11.6 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 79 80 81 83 84 85 A Algorithm Walkthrough 86 A.1 Iterative algorithms . . . . . . . . . . . . . . . . . . . . . . . . . 86 A.2 Recursive Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . 88 A.3 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 B Translation Walkthrough 91 B.1 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 C Recursive Vs. Iterative Solutions 93 C.1 Activation Records . . . . . . . . . . . . . . . . . . . . . . . . . . 94 C.2 Some problems are recursive in nature . . . . . . . . . . . . . . . 95 C.3 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 D Testing D.1 What constitutes a unit test? . D.2 When should I write my tests? D.3 How seriously should I view my D.4 The three A’s . . . . . . . . . . D.5 The structuring of tests . . . . D.6 Code Coverage . . . . . . . . . D.7 Summary . . . . . . . . . . . . E Symbol Definitions . . . . . . . . . . . . test suite? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .......

Words: 23014 - Pages: 93

Premium Essay

Discrete Maths

...above it. If the top layer has six logs, how many layers are there? Work: The 1st layer (the top one) has 6 logs The 2nd layer has 6+1(2) logs The 3rd layer has 6+2(2) The 4th layer has 6+3(2) ……………. The nth layer 6 +(n-1)(2) Total number of layers is: 6n +2(1+2+3+….+n-1) = 6n + 2(n-1)n/2 = 6n+n(n-1) = (n+5)n Then: n(n+5)=4n+110 n2+5n = 4n +110 n2 + n-110 =0 n = [-1441]/2 = [-121]/2 n = (-1+21)/2 = 10 (Taking the positive solution) Answer: 10 layers Exercise 4.2: 16. Give a recursive definition for the set of all a) positive even integers b) nonnegative even integers Answers: a) Let S the set of positive even integers Recursive definition of S: i) 2 S ii) If x S x+2 S b) Let S the set of nonnegative even integers Recursive definition of S: i) 2 S ii) If x S x+2 S Exercise 4.3: 10. If n ∈ Z+, and n is odd, prove that 8|(n2 − 1). Work: We will use the following property: Property: If we have 2 consecutive even numbers then 4 divides one of them n2-1= (n-1)(n+1) Since n is odd then n-1 and n+1 are consecutive even numbers Using the property above 4 divides n-1 or 4 divides n+1 If 4 divides n-1 Exists k in Z+ / 4k = n-1 Exists h in Z+ / 2h = n+1 Then (n-1)(n+1) = (4k)(2h) = 8kh So, n2-1 = 8(kh) and kh is in Z+ then 8n2-1 If 4 divides n+1 Exists k in Z+ / 2k = n-1 Exists h in Z+ / 4h = n+1 Then......

Words: 545 - Pages: 3

Free Essay

Hello World

...Syllabus Stanford University Autumn 2013 This is a tentative syllabus for CS 106B. All readings come from the Programming Abstractions in C++ textbook. Each unit is roughly 3-4 lectures in length. Near the end of each unit a corresponding homework assignment will be given. De pending on how quickly we finish material, we may end up spending more or less time on each topic. Readings are highly recommended but are not directly evaluated; for example, there are no in-class quizzes about readings. Unit 1 Topics Course Overview C++ Programming Language Basics Functions; Strings; Input/Output Streams Collections, Containers Abstract Data Types (ADTs) Stack/Queue, Vector, Grid, Map, Set, Lexicon Designing Classes Recursion Recursive Algorithms and Data Fractals Recursive Exhaustive Search Backtracking Sorting Algorithm Efficiency; Big-Oh Notation Arrays and Pointers Dynamic Memory Allocation Implementing Collection Classes Hashing Linked Lists Linked Data Structures Binary Trees; Binary Search Trees (BSTs) Graphs Advanced Topics Readings Chapters 1-4 Assignments HW1: Life 2 Chapters 5-6 HW2: Word Ladders, Random Writer 3 Chapters 7-8 HW3: Recursion 4 Chapters 9-10 HW4: Boggle 5 Chapters 11-12, 14 HW5: Priority Queue 6 Chapters 12, 14, 16 HW6: Huffman Encoding 7 Chapters 18-20 HW7: Trailblazer Please note that this is a preliminary rough schedule and is subject to change without advance notice. Refer to the course web......

Words: 268 - Pages: 2

Premium Essay

Cisco Router Exam Chapter 2

...the routing tables. Which three commands can be used to help troubleshoot Layer 3 connectivity issues? (Choose three.) ping show arp traceroute show ip route show interface show cdp neighbor detail 4. Refer to the exhibit. How will packets destined to the 172.16.0.0 network be forwarded? Router1 will perform recursive lookup and packet will exit S0/0. Router1 will perform recursive lookup and packet will exit S0/1. There is no matching interface associated with network 172.16.0.0 so packets will be dropped. There is no matching interface associated with network 172.16.0.0 so packets will take gateway of last resort and exit out S0/2. [pic] 5. A network administrator enters the following command into Router1: ip route 192.168.0.0 255.255.255.0 S0/1/0. Router1 then receives a packet that is destined for 192.168.0.22/24. After finding the recently configured static route in the routing table, what does Router1 do next to process the packet? drops the packet because the destination host is not listed in the routing table looks up the MAC address of the S0/1/0 interface to determine the destination MAC address of the new frame performs a recursive lookup for the IP address of the S0/1/0 interface before forwarding the packet encapsulates the packet into a frame for the WAN link and forwards the packet out the S0/1/0 interface 6. [pic] Refer to the exhibit. Which set of commands will configure static routes that will allow the WinterPark and the......

Words: 1947 - Pages: 8

Free Essay

The Merits of Uploading a Paper

...Matthew Hendrickson Tree Lab Questions 1. Recursive algorithms work well for trees because recursion allows for storing areas that have been traversed on the system stack, so that all avenues can be explored. Similar to the maze example from the chapter on recursion. Recursion also works well when the same steps have to be repeated on different parts of a data structure and is often simpler and more elegant than iteration with a loop. The same way an array is continuously broken and half and searched for a binary search, traversing a tree requires breaking a large tree into smaller trees. 2. Binary trees are only efficient when they are balanced. A balanced binary tree can be searched quickly, with growth of O(log n). If the tree is unbalanced, it can become similar to a linked list, which has a search growth of O(n). Inserting elements in binary trees requires similar operations no matter what type it is, and are similar to a Doubly Linked List in efficiency. The most efficient types of binary trees are self balancing. 3. A level order traversal requires the use of some kind of collection to hold all the elements in a level, then those items are searched in order. A Queue is the best type of collection for this, since the items can be added to the queue from left to right and then dealt with in order, for each level. A recursive level order traversal is possible, but it requires visiting each node twice, which makes it much less efficient than using a while loop......

Words: 269 - Pages: 2

Premium Essay

Eza Ma Bt3Rf Shi La Tkon 3la Ka2Mt Al2Sdk2 ..

...roles. In other words, role names are necessary in recursive relationships. 3.8 Describe two alternatives for specifying structural constraints on relationship types. What are the advantages of each? Two alternatives for specifying structural constraints on relationship types are cardinality ratio and participation. Cardinality ratio for a binary relationship specifies the number of relationship instances that an entity can participate in. The participation constraint specifies whether the existence of an entity depends on its being related to another entity via the relationship type. 3.9 Under what conditions can an attribute of a binary relationship type be migrated to become an attribute of one of the participating entity type? An attribute of a binary relationship type can be migrated to become an attribute of one the participating entity type when the relationship type is 1:1 or 1:N. This is because each entity participates in at most one relationship instance. However, for 1:N relationship type, a relationship attribute can be migrated only to the entity type at the N-side of the relationship. 3.10 When we think of relationships as attributes, what are the value sets of these attributes? What class of data models is based on this concept? The value sets of these attributes 3.11 What is meant by a recursive relationship type? Give some examples of recursive relationship types? A recursive relationship type exists if an entity can......

Words: 1644 - Pages: 7

Premium Essay

International Monetary Fund

...significant negative relationship between inflation and growth. This relationship holds at all but the lowest inflation rates and is robust across various samples and specifications. The method of binary recursive trees identifies inflation as one the most important statistical determinants of growth. Finally, while there are short-run growth costs of disinflation, these are only relevant for the most severe disinflations, or when the initial inflation rate is well within the single-digit range. JEL Classification Numbers: E31, 040. Keywords: inflation, growth determinants, growth regressions, robustness. Authors' E-Mail Addresses: Aghosh@imf.org; Sphillips@imf.org 1 We would like to thank Kadima Kalonji for research assistance, and Alan Taylor and Maurice Obstfeld for making available their computer programs. Hugh Bredenkamp, Sharmini Coorey, Peter Doyle, Stanley Fischer, Manuel Guitian, Javier Hamann, Timothy Lane, Michael Sarel, Susan Schadler, and Tsidi Tsikata provided helpful comments on an earlier draft, as did Matthew Canzonieri, Martin Evans, and others at a March 1998 seminar at Georgetown University. -2- Contents Page Summary 1. Introduction 2. Basic Statistics and Correlations 3. Multivariate Inflation-Growth Regressions 4. Robustness 5. Binary Recursive Trees 6. The Issue of Simultaneity 7. Disinflation and Growth 8. Conclusions . Tables 1. 2. 3. 4. 5. 6. Figures 1. 2. 3. 4. 5a. 5b. 6. 7. References Joint Frequency Distribution of Inflation......

Words: 2757 - Pages: 12

Premium Essay

Dns Terminology

...called an “EPP code” or a “transfer code”) is a string, usually between 8 and 16 characters long and randomly created at the time of a domain’s registration, used to authorize transfers in certain Top Level Domains. The auth code provides an extra layer of security over the normal transfer request procedures. Authoritative Nameserver A nameserver which has been configured to provide answers for a specific domain, rather than simply getting and caching data about domains from other nameservers. Border Gateway Protocol BGP performs routing between multiple autonomous systems (domains) by finding the best path. Cache Caching refers to a process where Recursive DNS servers remember the results of a DNS query for the time specified in the TTL (Time to Live). This reduces DNS query traffic as the Recursive DNS server already knows the answer. Once the TTL expires, the answer is removed from the cache. THE MASTER LIST OF DNS TERMINOLOGY / 3 CDN DDoS A Content Delivery Network is a network of servers that serves content to end users from the closest node for the fastest load time. Distributed Denial of Service is an attack when multiple systems are used to flood servers with traffic in an attempt to overwhelm its available resources (bandwidth, memory, processing power, etc), making it unavailable to respond to legitimate users. CNAME A CNAME is a special type of DNS record used to create an alias from one hostname to another. For......

Words: 2131 - Pages: 9

Free Essay

Hostel

...count *10; } system ("pause"); return 0; } 2. Analysis: n=3count1=count-3+1 T(n) =count-2 =O(count) =O(n) 3. Table n-th Fibonacci no. | Time 1(sec) | Time 2(sec) | Time 3(sec) | Average(sec) | 10 | 0.001 | 0.001 | 0.001 | 0.001 | 100 | 0.001 | 0.001 | 0.001 | 0.001 | 1’000 | 0.002 | 0.001 | 0.001 | 0.0013 | 10’000 | 0.003 | 0.002 | 0.001 | 0.0020 | 100’000 | 0.003 | 0.001 | 0.002 | 0.0020 | 1’000’000 | 0.007 | 0.006 | 0.007 | 0.0067 | 10’000’000 | 0.053 | 0.048 | 0.047 | 0.0493 | 100’000’000 | 0.483 | 0.454 | 0.475 | 0.4706 | 1’000’000’000 | 4.495 | 4.612 | 4.503 | 4.5367 | 10’000’000’000 | 44.401 | 45.114 | 44.984 | 44.833 | 4. Graph b. Recursive Fibonacci 1. Code: #include <iostream> #include <time.h> using namespace std; //recursive Fibonacci long long fib(int x) { if (x == 0) return 0; if (x == 1) return 1; else { return fib(x-1)+fib(x-2); } } int main() { //variables time_t start,end; int count=10; //loop until 80th Fibonacci while (count<=40) { start = clock(); //start timer cout << "Fibonacci Number: " <<fib(count)<<endl; //call function //end timer show Runtime end=clock(); double diff ((double)(end - start)); double time = diff / CLOCKS_PER_SEC; cout<<"Runtime ("<< count <<"th) : "<< time <<"......

Words: 4123 - Pages: 17

Free Essay

Solenet

...and Computers . . 1.2 Measuring Computing Power . . . . . . . 1.2.1 Information . . . . . . . . . . . . . 1.2.2 Representing Data . . . . . . . . . 1.2.3 Growth of Computing Power . . . 1.3 Science, Engineering, and the Liberal Arts 1.4 Summary and Roadmap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2 3 3 8 12 13 16 Part I: Defining Procedures 2 Language 2.1 Surface Forms and Meanings 2.2 Language Construction . . . . 2.3 Recursive Transition Networks 2.4 Replacement Grammars . . . 2.5 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 19 20 22 26 32 3 Programming 3.1 Problems with Natural Languages . . . . 3.2 Programming Languages . . . . . . . . . 3.3 Scheme . . . . . . . . . . . . . . . . . . . 3.4 Expressions . . . . . . . . . . . . . . . . . 3.4.1 Primitives . . . . . . . . . . . . . 3.4.2 Application Expressions . . . . . 3.5 Definitions . . . . . . . . . . . . . . . . . 3.6......

Words: 58807 - Pages: 236

Premium Essay

Path Analysis

...การวิเคราะห์โมเดลลิสเรลพิสูจน์ความสัมพันธ์เชิงสาเหตุได้ สัญลักษณ์ของโมเดลเชิงสาเหตุ ตัวแปรที่สังเกตได้ ตัวแปรแฝงหรือองค์ประกอบ ปลาย หัว ตัวแปรปลายมีผลโดยตรงต่อตัวแปรหัว (ความสัมพันธ์เชิงสาเหตุ) ตัวแปรมีความสัมพันธ์กัน ตัวแปรที่สังเกตได้ X มีอิทธิพลโดยตรงขนาด ต่อการเปลี่ยนแปลงที่สังเกตได้ Y โดยมีความคลาดเคลื่อนสุ่มในการทำนายขนาด ตัวแปรที่สังเกตได้ X1 และ X1 มีความสัมพันธ์กัน โดยมีความแปรปรวนร่วมเท่ากับ ประเภทของโมเดลเชิงสาเหตุ (Causal or Relationshep Model) * Manifest(Observed) / Latent (Unobserved) * Recursive / Non- Recursive Manifest(Observed) Multiple Regression Analysis, Path Analysis Latent (Unobserved) Factor Analysis * Recursive ทางเดียว * Non- Recursive ย้อนกลับ การสร้างโมเดลเชิงสาเหตุ การวิเคราะห์โมเดลเชิงสาเหตุ * Regression Model * Path Model * Factor Analysis Model * EFM * CFM * Covariance Structure Model = LISREL Regression Model Model (Multiple regression) : ตัวอย่าง Path Model Model : ตัวแปรอยู่ในรูปของคะแนนมาตรฐาน Y= XB+e ตัวอย่าง แสดงความสัมพันธ์ระหว่าง X1 - X4 โดย X1 ไม่ได้ถูกกำหนดโดยตัวแปรใด(Exogenous V.) X2-X4 ถูกกำหนดโดยตัวแปรใดตัวแปรหนึ่งในโมเดล (Endogenous V.) การวิเคราะห์โมเดลเชิงสาเหตุ Factor Analysis Model Exploratory Factor Model: EFM Model :......

Words: 921 - Pages: 4

Free Essay

Computer Theory

...L2 ii) if w L2, then so is wxw L2 Find all strings in L2 with length less than 7 characters (note: ‘w’ is a meta symbol). 3. (7 pts.) Consider the recursively defined language, L3: i) ac L3 and gbb L3 ii) if w L3, then so is gwa L3 Find all strings in L3 with length less than 9 characters (note: ‘w’ is a meta symbol). 4. (7 pts.) Given the alphabet {xyz abc}, give a recursive definition for the language whose words do not contain the string xyzxyz. Notes: a. Treat ‘xyz’ and ‘abc’ as single letters (i.e. atomic tokens that cannot be decomposed). b. This must be a constructive definition (i.e. in the definition, you cannot say what is not in the language. That is, the definition cannot use constructs like: ‘not,’, ≠, +. Also you cannot use exponents in the meta variable: w+,w2. You can use repeated variables, ww or multiple variables w, x. These same constraints apply to all of the remaining recursive questions. Basically, they should look similar to Questions 2 and 3 above. 5. (7 pts.) Given the alphabet {xyz abc}, give a recursive definition for the language whose words contain the string xyzxyz (note: there are an infinite number of words in this language, same constraints as in Question 4. 6. (10 pts.) Let L = {x yy xxy} Which of the following strings are in L*, which are not? Show why you answered yes or no. a. yyxxxy, b. xyyyxxyy, c. xyyxyyxxxyy, d. yyxyyxxyxy, e. yyxyyxxyyy 7. (5......

Words: 672 - Pages: 3