Hot answers tagged

6

Well, you wanted some tips, so here are a few thoughts on it. You know that you have to create the correct number of rows, you have that part. Now, you need to think about how to create the spaces and hashes. Well, break it down into smaller and smaller parts. You need to think about how to build a given row. OK, that's a smaller part. What is a row? It'...


2

place 2 "for loops", 1 for spaces and 1 for dashes inside your row "for loop"... tip its a double loop in a loop. your ("\n") needs to be outside your two inner loops. now getting it to work is a different story! but that's a way for it to be done.


1

Let's see if I can point you in the right direction here. For spaces, for (int s = i-1; s >= r; s--) is giving you one too many spaces every time because of the test condition. Let's check out a height of 1. You want 0 spaces, but look what happens. i=1, so s= 1-1 = 0. On the first iteration, s >= i-1 tests as 0 >= 0 which evaluates as true. So, it ...


1

Here is a pseudocode for this program: For 0 times print spaces For 1 time print newline For Height + 1 times print hash For 0 times print spaces: for (spaces = 0; spaces > Height; spaces--). This will run as long as spaces is greater than Height. Since spaces is initialized to 0 , and Height must be greater-equal to 0, spaces is never greater than ...


1

Please try to understand the pset questions, once you do take small steps and write down problem requirements in word and then transform those into the code exactly as per the specifications. Follow these steps: 1- Prompt the user for the half-pyramid height and print height (You are actually doing it half wrong like using undeclared variable rows and ...


1

Let's assume at first that we want to store all the users in a database. In the first case we use the first letter of their name as the index value, and we link the user behind the previous one, if there is already a user with a name that starts with the same letter. For example we have the array ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', '...


1

Your conclusion of "But this is not true. Right? Because if each element is inserted at one index in the hash table then it is as good as my linked list. Right?" is incorrect. If you have what is called a perfect hash (every element hashes to a different number), and each element is inserted into a different index, then it does indeed run at O(1). The key ...


Only top voted, non community-wiki answers of a minimum length are eligible