Skip to main content

All Questions

0votes
1answer
107views

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
2votes
1answer
1kviews

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
3votes
3answers
531views

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
5votes
1answer
261views

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
2votes
2answers
252views

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
5votes
2answers
493views

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
4votes
1answer
303views

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
4votes
1answer
112views

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
3votes
1answer
3kviews

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
13votes
3answers
23kviews

Math expression solver

I've recently stumbled upon an interesting challenge for me: You should develop C application, that solves math expressions. Operations such as (+,-,*,/) should be supported, as well as (cos, sin, ...
Vladimir Tagakov's user avatar
7votes
4answers
12kviews

Calculating a specific entry in a Pascal’s triangle recursively

Our task was to calculate the entry of a Pascal’s triangle with a given row and column recursively. The triangle was specified in a way that the tip of the triangle is ...
kleinfreund's user avatar
0votes
2answers
958views

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
5votes
1answer
6kviews

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
3votes
2answers
2kviews

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
1vote
1answer
329views

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

153050per page
close