This document provides code for a C++ program that checks if a given word is a palindrome using stacks and queues. The program defines Stack and Queue classes with push, pop, enqueue, and dequeue methods. An palindrome function takes a word as a char array, pushes and enqueues the letters to a stack and queue, then pops and dequeues to check if the first and last letters are equal, all the way to the middle of the word. It returns 1 if the word is a palindrome or 0 if it is not. The main function prompts the user for input, calls the palindrome function, and prints the result.
Java Cheat Sheet includes the following contents:
- Data Types
- Statements
- String, ArrayList and HashMap Methods
- Conversion
- Operators
- Exception Handling
Though Language INtegrated Query provides a revolutionary way to write code in C# 3.0 and Visual Basic 9, it is powerless without several enabling language features and libraries. This session will explore the technologies that make LINQ possible and show how you can use the same techniques to make LINQ work for you.
Presented Aug. 28 & 29, 2009 at St. Louis Day of .NET
Java Cheat Sheet includes the following contents:
- Data Types
- Statements
- String, ArrayList and HashMap Methods
- Conversion
- Operators
- Exception Handling
Though Language INtegrated Query provides a revolutionary way to write code in C# 3.0 and Visual Basic 9, it is powerless without several enabling language features and libraries. This session will explore the technologies that make LINQ possible and show how you can use the same techniques to make LINQ work for you.
Presented Aug. 28 & 29, 2009 at St. Louis Day of .NET
Are you a C# developer who has embraced the language’s functional concepts such as lambda expressions and LINQ, but have not yet embraced F#?
In this talk I’ll compare and contrast code written in both C# and F# that will highlight the differences between the two languages while also showing how a functional-first language like F# can be a great tool for solving problems.
Presented at DevWeek (25th March 2015)
These days, testing is considered a sexy topic for programmers. Who’d have thought it? But what makes for good unit tests (GUTs)? There’s more to effective unit testing than just knowing the assertion syntax of a testing framework.
Testing represents a form of communication and, as such, it offers multiple levels and forms of feedback, not just basic defect detection. Effective unit testing requires an understanding of what forms of feedback and communication are offered by tests, and what styles encourage or discourage such qualities.
What style of test partitioning is most common, and yet scales poorly and is ineffective at properly expressing the behaviour of a class or component? What styles, tricks and tips can be used to make tests more specification-like and can scale as the codebase grows?
This session will address these questions and outline exactly what makes a good unit test.
Are you a C# developer who has embraced the language’s functional concepts such as lambda expressions and LINQ, but have not yet embraced F#?
In this talk I’ll compare and contrast code written in both C# and F# that will highlight the differences between the two languages while also showing how a functional-first language like F# can be a great tool for solving problems.
Presented at DevWeek (25th March 2015)
These days, testing is considered a sexy topic for programmers. Who’d have thought it? But what makes for good unit tests (GUTs)? There’s more to effective unit testing than just knowing the assertion syntax of a testing framework.
Testing represents a form of communication and, as such, it offers multiple levels and forms of feedback, not just basic defect detection. Effective unit testing requires an understanding of what forms of feedback and communication are offered by tests, and what styles encourage or discourage such qualities.
What style of test partitioning is most common, and yet scales poorly and is ineffective at properly expressing the behaviour of a class or component? What styles, tricks and tips can be used to make tests more specification-like and can scale as the codebase grows?
This session will address these questions and outline exactly what makes a good unit test.
Problem solving strategies in mathematics and computer scienceUT, San Antonio
This presentation was placed on a course project of reading course in the university of texas, san Antonio. This is a group project and the project lead was Lishu Li
Programs are complete in best of my knowledge with zero compilation error in IDE Bloodshed Dev-C++. These can be easily portable to any versions of Visual Studio or Qt. If you need any guidance please let me know via comments and Always Enjoy Programming.
I need to fill-in TODOs in .cpp file and in .h file Could some.pdfforladies
I need to fill-in //TODO\'s in .cpp file and in .h file
Could someone help me at least with few of them to give me an idea how deal with it.
***SinglyLinkedList.cpp
#include
#include
#include \"SinglyLinkedList.h\"
void test_constructor() {
SinglyLinkedList lst = {100, 200, 300, 400, 500};
assert(*lst.at(0) == 100);
assert(*lst.at(1) == 200);
assert(*lst.at(2) == 300);
assert(*lst.at(3) == 400);
assert(*lst.at(4) == 500);
assert(lst.size() == 5);
}
void test_remove() {
SinglyLinkedList lst = {100, 200, 300, 400, 500};
lst.remove(2);
assert(*lst.at(0) == 100);
assert(*lst.at(1) == 200);
assert(*lst.at(2) == 400);
assert(*lst.at(3) == 500);
assert(lst.size() == 4);
}
void test_insert() {
// TODO
}
void test_push_back() {
// TODO
}
void test_push_front() {
// TODO
}
void test_append() {
// TODO
}
void test_sum() {
// TODO
}
int main() {
test_constructor();
test_remove();
test_insert();
test_push_back();
test_push_front();
test_append();
test_sum();
}
***SinglyLinkedList.h
#include
#include
template
class SinglyLinkedList {
// Nested class representing the nodes in the list.
class SinglyLinkedListNode {
public:
// The value stored in this node.
T value;
// The next node in the sequence.
SinglyLinkedListNode *next;
SinglyLinkedListNode(T value) :
value(value), next(nullptr) {}
SinglyLinkedListNode(T value, SinglyLinkedListNode *next) :
value(value), next(next) {}
// Return the size (length) of the linked list.
std::size_t size();
};
SinglyLinkedListNode *head;
SinglyLinkedListNode *tail;
public:
// Constructs a new SinglyLinkedList from an initializer_list of type T[].
// This is mostly for convenience, especially when testing.
SinglyLinkedList(std::initializer_list items) : head(nullptr), tail(nullptr) {
if (items.size() == 0) {
return;
}
// initializer_lists were designed to be used iteratively,
// so thats what we do.
// Can you think of how to write this recursively?
auto it = items.begin();
while (it != items.end()) {
this->push_back(*it++);
}
}
// Return a pointer to the value at the given index.
// If the index is larger than the size of the list,
// return a nullptr.
//
// ASIDE: We will cover exceptions later.
T* at(std::size_t i);
// Pushes a new node onto the back of the list.
void push_back(T value);
// Pushes a new node onto the front of the list.
void push_front(T value);
// Return the size (length) of the linked list.
std::size_t size();
// Remove the specified node from the list.
void remove(std::size_t i);
// Insert the value at the index.
void insert(std::size_t i, T value);
// Append the given list to this one.
void append(SinglyLinkedList list);
};
template
T* SinglyLinkedList::at(std::size_t i) {
// TODO
}
template
void SinglyLinkedList::push_back(T value) {
// TODO
// Make sure that this is a O(1) operation!
}
template
void SinglyLinkedList::push_front(T value) {
// TODO
// Make sure that this is a O(1) operation!
}
template
void SinglyLinkedList::remove(std::size_t i) {
// TODO
// Don\'t forget to not only unlink the node, b.
Program to sort the n names in an alphabetical orderSamsil Arefin
It is a cpp program.Sort names by alphabetical order.
Users give some names as input and they will get sorted name by alphabetical order.I think that it may be helpful to others
#include<iostream>
#include<cctype>
using namespace std;
class evalPostFix
{
public:
int s[50];
int top;
char str[50];
evalPostFix() {
top=-1;
}
void push(int val) {
top++;
s[top]=val;
}
int pop() {
int val=s[top];
top--;
return val;
}
int oper(int x,int y,char op) {
switch(op) {
case '+':return x+y;
case '-':return x-y;
case '*':return x*y;
case '/':return x/y;
default: return 0;
}
}
int calc();
};
int evalPostFix::calc() {
int i=0;
while(str[i]!='=') {
if(isdigit(str[i])) {
push(str[i]-'0');
}
else {
int x=pop();
int y=pop();
int r=oper(x,y,str[i]);
push(r);
}
i++;
}
return pop();
}
int main()
{
char answer;
evalPostFix eval;
do
{
cout<<"Enter a postfix expression:" << endl;
cin>>eval.str;
int r=eval.calc();
cout<<"Final Value : "<<r <<"\n";
cout << "Continue (Y or N)" << endl;
cin >> answer;
}
while(answer!='N');
system("pause");
}
Here is the output, but I do not want it to be like this.
I want the output to be like this
...
Programing with java for begniers .pptxadityaraj7711
Java is a high-level, object-oriented programming language developed by Sun Microsystems in the mid-1990s (now owned by Oracle Corporation). It is widely used for building a variety of applications, including desktop, web, mobile, and enterprise software. Java's design emphasizes portability, simplicity, and security, making it one of the most popular programming languages in the world.
### Importance of Java:
1. **Platform Independence**:
- Java programs can run on any device or operating system that supports the Java Virtual Machine (JVM).
- This "write once, run anywhere" (WORA) capability makes Java applications highly portable.
2. **Object-Oriented Programming (OOP)**:
- Java supports key OOP principles such as inheritance, encapsulation, polymorphism, and abstraction.
- These principles enable developers to create modular and reusable code.
3. **Rich Ecosystem and Libraries**:
- Java has a vast ecosystem of libraries, frameworks, and tools that facilitate development across various domains.
- Popular frameworks like Spring, Hibernate, and Apache Struts streamline development in enterprise environments.
4. **Robustness and Reliability**:
- Java has strong exception handling and type-checking mechanisms that contribute to the robustness and reliability of applications.
5. **Community and Support**:
- Java has a large and active developer community, providing support and resources for learning and troubleshooting.
- Java's extensive documentation and community forums are valuable resources for developers.
6. **Performance**:
- Java's just-in-time (JIT) compilation allows for optimized execution, improving performance.
- Java can handle large-scale applications and complex computations efficiently.
7. **Security**:
- Java's architecture includes features such as runtime security checks and a security manager for safe execution.
- This makes it a preferred choice for developing secure applications.
8. **Enterprise Applications**:
- Java is a dominant language in enterprise development due to its scalability, stability, and compatibility with existing systems.
- Many businesses rely on Java for mission-critical applications.
9. **Career Opportunities**:
- Proficiency in Java opens up many career opportunities, particularly in enterprise development, finance, healthcare, and telecommunications.
10. **Future-Proofing**:
- Java's continuous updates and compatibility with emerging technologies ensure that it remains relevant and future-proof.
Overall, Java's versatility, reliability, and widespread adoption make it an essential language for developers across various industries
Questions has 4 parts.1st part Program to implement sorting algor.pdfapexelectronices01
Questions has 4 parts.
1st part: Program to implement sorting algorithms:
#include
#include
#include
using namespace std;
void swap(std::vector & data, int i, int j)
{
int tmp = data[i];
data[i] = data[j];
data[j] = tmp;
}
void print(std::vector const & data)
{
std::vector::const_iterator iter = data.begin();
for (; iter != data.end(); ++iter)
{
cout << *iter << \" \";
}
if (data.size() > 0)
{
cout << endl;
}
}
int generateRandom(int low, int high);
void Shuffle(std::vector & data)
{
int length = data.size();
for (int i = 0; i < length-1; ++i)
{
swap(data, i, generateRandom(i+1, length-1));
}
print(data);
}
int generateRandom(int low, int high)
{
srand(low);
int gen = 0;
gen = rand() % (high - low + 1) + low;
return gen;
}
//useful for small lists, and for large lists where data is
//already sorted
void BubbleSort(std::vector & data)
{
int length = data.size();
for (int i = 0; i < length; ++i)
{
bool swapped = false;
for (int j = 0; j < length - (i+1); ++j)
{
if (data[j] > data[j+1])
{
swap(data, j, j+1);
swapped = true;
}
}
if (!swapped) break;
}
}
//useful for small lists and where swapping is expensive
// does at most n swaps
void SelectionSort(std::vector & data)
{
int length = data.size();
for (int i = 0; i < length; ++i)
{
int min = i;
for (int j = i+1; j < length; ++j)
{
if (data[j] < data[min])
{
min = j;
}
}
if (min != i)
{
swap(data, i, min);
}
}
}
//useful for small and mostly sorted lists
//expensive to move array elements
void InsertionSort(std::vector & data)
{
int length = data.size();
for (int i = 1; i < length; ++i)
{
bool inplace = true;
int j = 0;
for (; j < i; ++j)
{
if (data[i] < data[j])
{
inplace = false;
break;
}
}
if (!inplace)
{
int save = data[i];
for (int k = i; k > j; --k)
{
data[k] = data[k-1];
}
data[j] = save;
}
}
}
void Merge(std::vector & data, int lowl, int highl, int lowr, int highr);
void MergeSort(std::vector & data, int low, int high)
{
if (low >= high)
{
return;
}
int mid = low + (high-low)/2;
MergeSort(data, low, mid);
MergeSort(data, mid+1, high);
Merge(data, low, mid, mid+1, high);
}
void Merge(std::vector & data, int lowl, int highl, int lowr, int highr)
{
int tmp_low = lowl;
std::vector tmp;
while (lowl <= highl && lowr <= highr)
{
if (data[lowl] < data[lowr])
{
tmp.push_back(data[lowl++]);
}
else if (data[lowr] < data[lowl])
{
tmp.push_back(data[lowr++]);
}
else
{
tmp.push_back(data[lowl++]);
tmp.push_back(data[lowr++]);
}
}
while (lowl <= highl)
{
tmp.push_back(data[lowl++]);
}
while (lowr <= highr)
{
tmp.push_back(data[lowr++]);
}
std::vector::const_iterator iter = tmp.begin();
for(; iter != tmp.end(); ++iter)
{
data[tmp_low++] = *iter;
}
}
int Partition(std::vector & data, int low, int high);
void QuickSort(std::vector & data, int low, int high)
{
if (low >= high) return;
int p = Partition(data, low, high);
QuickSort(data, low, p-1);
QuickSort(data, p+1, high);
}
int Partition(std::vector & data, int low, int high)
{
int p = low;
for (int i = p+1; i <= high; ++i)
{
if (data[i] < data[p])
{
swap.
1. Data Structure
Data Structure and File Management
Course Work
Mark Green
Excelsior Community College
Amis 2A (Evening)
March 3, 2011
2. Question 1 Solution
#include <iostream.h>
#include <stdio.h>
#include <string.h>
#include<conio.h>
using namespace std;
class Stack {
private:
char letters[50];
int size;
public:
Stack() {
size = -1;
}
void push(char p);
char pop();
int getSize();
};
void Stack::push(char p) {
if (size < 50) {
letters[++size] = p;
}
3. }
char Stack::pop() {
if (size != -1) {
return letters[size--];
}
}
class Queue {
private:
char letters[50];
int size;
int start;
public:
Queue() {
start = 0;
size = 0;
};
void enqueue(char p);
char Dequeue();
};
void Queue::enqueue(char p) {
if (size < 50) {
4. letters[size] = p;
size++;
}
}
char Queue::Dequeue() {
char value;
if (start < size) {
value = letters[start];
start++;
return value;
}
}
int palindrome(char *word) {
Stack stack;
Queue queue;
int check = 1; // this is a palindrome until proven that this is not the case
int len = strlen(word);
for (int i = 0; i < len; i++) {
stack.push(word[i]);
queue.enqueue(word[i]);
}
5. // This condition perform the palindrome test
char j,q;
for (int i = 0; i < len / 2; i++) {
char j = stack.pop();
char s = queue.Dequeue();
if (j != s) {
check = 0;
}
}
return check;
}
int main() {
char words[60];
cout << "Please Imput Data :";// The user is prompt to enter the data item
gets(words);
if (palindrome(words)) {
cout << "Words is a palindrome t";
} else {
cout << "this is not a palindrome t";
}
system("pause");