1 / 33

CSC 335 Review Game

CSC 335 Review Game. Exam 2. Teams. Rex, Evan, Eric, George Emily, Brian, Sam, Alex Dawson Jacapo , Ryan, Emma, Becca Todd, James, Josh, Peter T Peter D, Nick , Colin, Alex Daniels Asher, Matt, Chad, Heather. Individual Round. 1. What are the values of x & y at the end? int x = 3;

sheila
Télécharger la présentation

CSC 335 Review Game

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSC 335 Review Game Exam 2

  2. Teams • Rex, Evan, Eric, George • Emily, Brian, Sam, Alex Dawson • Jacapo, Ryan, Emma, Becca • Todd, James, Josh, Peter T • Peter D, Nick, Colin, Alex Daniels • Asher, Matt, Chad, Heather

  3. Individual Round

  4. 1. • What are the values of x & y at the end? int x = 3; int y = 1; y = ++x;

  5. 2. What is printed? int *ptr; int x = 5; ptr = &x; *ptr = 4; printf(“%d”, x);

  6. 3. • Finish the function: int add(int *a, int *b){ return __________; }

  7. 4. • Call the function: int f = 712; int g = 63; int sum = add(____,____); int add(int *a, int *b){

  8. 5. • Which is true of C? • It is a third-generation language. • It is imperative. • It is procedural.

  9. 6. • What is y? y = [x % 2 ==1 for x in range(1,6)]

  10. 7. • What is y? y = [x for x in range(1,6) if x%3 ==1]

  11. 8. • What regular expression matches ten symbols (letters, numbers, spaces, whatever) followed by zero or one a?

  12. 9. • Describe Prolog in terms of: - Declarative/Procedural? - Compiled/ Interpreted?

  13. 10. • Describe Prolog in terms of • Paradigm • Generation

  14. 11. • Do they unify? a(b(X),X,c(d(Y))) with a(Z,e,c(A))

  15. 12. • What does it do? mystery([4|T], X):- mystery(T,X1), X is X1+1. mystery([H|T],X):-mystery(T,X).

  16. 13. • What language does it generate? S -> AB A -> aA | a B -> bbb

  17. 14. • What makes a language context-free?

  18. 15. • If L1 = {abn, n> 0} and L2 = {anb2n, n>0} what is L1 intersect L2?

  19. 16. • How do you prove a language is ambiguous?

  20. 17. • What is special about a line of C code that starts with the # symbol?

  21. 18. • Consider the language anbn. Is it: • Regular • Context-free • Both • Neither

  22. 19. • When might you declare a C variable with the “register” keyword? You need a register variable if it is a primitive that you know you are going to access a lot.

  23. 20. • What is aliasing? Aliasing is having 2 names for the same address in memory.

  24. 21. • Which regular expression gives an odd number of a’s? r’(aa)*a’

  25. 22. • What language does it generate? S -> abS | ab Regular expression would be (ab)+. That is, ab as a pair occurring one or more times.

  26. 23. • If L1 = {abn, n> 0} what is L12? • L12 = {abnabm, n,m> 0}

  27. 24. • Which can you write a PDA for? • A: {anbn+2, n > 0} • B: {wLwR, w is any string of a’s and b’s, L has only a’s} • C: {Any string where the number of a’s is twice the number of b’s} All of them.

  28. All-Play

  29. All-Play • What is the result for the different passing schemes? global int z = 0; func(z); write(z); void func(int x){ x = z+1; z= z+10; }

  30. Write regular expressions • String is either 4 or 5 digits. • String is either 40 or 50 digits. • String includes 2 of the same number.

  31. Write the grammar: • L = {anbm, m>=n+2}

  32. Write a prolog predicate that takes a number and generates a list of that number down to one. • generate(+Num, -List) • Example: generate(5,L) givesL=[5,4,3,2,1]

  33. All-play • Draw a PDA for the language: • anbm: n > m

More Related