Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
1 answer
107 views

Printing Permutations

Following is a leetcode problem: Given an array nums of distinct integers, return all the possible permutations. You can return all the possible permutations. You can return the answer in any order. ...
Strange Alchemist's user avatar
2 votes
1 answer
1k views

Drawing dragon curves using Turtle graphics

This is exercise 3.2.23. from the book Computer Science An Interdisciplinary Approach by Sedgewick & Wayne: Write a recursive Turtle client that draws dragon fractal. The following is the data-...
Khashayar Baghizadeh's user avatar
5 votes
1 answer
262 views

Drawing a Thue-Morse pattern recursively

This is web exercise 3.1.63. from the book Computer Science An Interdisciplinary Approach by Sedgewick & Wayne: Write a program that reads in a command line input N and plots the N-by-N Thue-...
Khashayar Baghizadeh's user avatar
2 votes
2 answers
261 views

Write a recursive function that takes a positive integer n and plots an N-by-N Hadamard pattern where N = 2^n

This is web exercise 2.3.20. from the book Computer Science An Interdisciplinary Approach by Sedgewick & Wayne: Write a recursive program that takes a command-line argument n and plots an N-by-N ...
Khashayar Baghizadeh's user avatar
4 votes
1 answer
112 views

Printing Gray code through modifying Samuel Beckett's stage instructions

This is exercise 2.3.24. from the book Computer Science An Interdisciplinary Approach by Sedgewick & Wayne: Modify Beckett to print the Gray code. Beckett refers to the following program within ...
Khashayar Baghizadeh's user avatar
4 votes
1 answer
305 views

Minimax based Tic Tac Toe

I am attempting to make an unbeatable Tic Tac Toe game using a simplified minimax algorithm. The code looks like this: ...
qwerty's user avatar
  • 361
5 votes
2 answers
520 views

How to optimize Karatsuba algorithm (using arraylist and java)

I was using Karatsuba algorithm to multiply two polynomials and return the coefficients and I am using java, we are asked to use arraylists here, however, my code is too complicated and it takes much ...
Jenny's user avatar
  • 51
3 votes
3 answers
532 views

Sudoku Solver questions on style and algorithm

I am working towards a CSC degree right now and wanted to try and practice writing good code that could be easily maintained and read in industry. I wrote the following program in Java that takes a ...
Luke Kelly's user avatar
3 votes
1 answer
3k views

Java n-ary Tree class with custom made methods and nested Node class

I'm a beginner and I wrote this (working) code for n-ary tree. The specifics: Each node is to be built with an integer value. Each node has a variable number of children. The nodes should have an ...
Ary's user avatar
  • 41
1 vote
1 answer
335 views

Rearrange an array in place such that the first and last halves are interleaved

Given an array of n elements in the following format { a1, a2, a3, a4, ….., an/2, b1, b2, b3, b4, …., bn/2 }. The task is shuffle the array to {a1, b1, a2, b2, a3, b3, ……, an/2, bn/2 } without ...
Anirudh Thatipelli's user avatar
0 votes
2 answers
971 views

Number of Paths (BackTracking) in Java

Illustration You're testing a new driverless car that is located at the Southwest (bottom-left) corner of an n×n grid. The car is supposed to get to the opposite, Northeast (top-right), corner ...
Anirudh Thatipelli's user avatar
3 votes
2 answers
2k views

Recursive Contains Method

The method below recursively checks if a string contains another string. Example: contains(hello, lo, 0) should return true, ...
perspicuousreading's user avatar
5 votes
1 answer
6k views

Replacing characters in a Java string using iteration and recursion

I am new to the whole Data Structures thing and I want to get better at writing efficient code. So, I have been practicing some problem sets. The questions is - Replace characters in a string using ...
Melissa Bundy's user avatar
-7 votes
1 answer
1k views

Counting number of steps while finding right path [closed]

I am writing a code which would return the path in a maze using recursion, but now with the path I also want the number of steps. How do count number of steps in this program? or number of times ...
user10859's user avatar
5 votes
3 answers
5k views

Using recursion to count substrings (with exceptions to the rule) in Java

I am going through the CodingBat exercises for Java. Here is the one I have just finished: Given a string, compute recursively the number of times lowercase hi ...
alanbuchanan's user avatar
  • 1,312

15 30 50 per page