CSE 14 Study Guide - Final Guide: Linked List

92 views9 pages
15 Oct 2018
School
Course
Professor

Document Summary

Write a static method findindex() that accepts an array of string ar, and a string s. The array is traversed, and the index of the first occurrence of s is returned. If no occurrence of s is found, -1 is returned. Given the following program, complete the methods below: class question1{ public static void main(string[] args){ int[][] twod = {{3,6,4,7}, {2,3}, {8,5,6}}; int a = findhighest(twod); int b = findsum(twod); // this method should find the highest value in the. // 2d array. public static int findhighest(int[][] z){ // this method should find the sum of elements in. // the 2d array. public static int findsum(int[][] y){ Complete the recursive method fib() below such that the method computes values in the fibonacci sequence. The fibonacci sequence is defined by: fib(0) = 1, fib(1) = 1 integer x > 1: fib(x) = fib(x - 1) + fib(x - 2) int fib(int x){