There is a set of N men and N women. Each of them is numbered from 1 t...

Code in java

There is a set of N men and N women. Each of them is numbered from 1 to N. They have been married off in pairs. However complete information about the pairs is not available. Some specific clues about the pairs are available. These clues are either of the form:

ith woman, indicated as Wi, is paired with the man Mj

or

woman Wp is not paired with the man Mq

If Wi is paired with Mj then they cannot pair with anyone else.

Given the number N and the clues, you have to write a program, which deduces the complete pairing.

Consider the case where N = 3 and the clues are:

  1. W1 is paired with M2
  2. W3 is not paired with M1

Consider the case of woman W3. She cannot be paired with M1 (given as clue 2). She cannot be paired with M2 either as deducible from clue 1. This leaves only M3 to pair with her. Further, now W2 can only pair with M1 since both M2 and M3 are already paired off.

Input Format

  • The first line contains an integer N denoting the number of pairs
  • The second line contains an integer C denoting the number of clues which follow
  • Each of the next C lines contains a clue of the form

= 1 2

which means woman W1 is paired with man M2

OR

# 3 1

which means woman W3 is not paired with man M1

Constraints

1<= N <=100

0<= C <=100

Output Format

You have to print the sequence of integers, each separated by a space, on a single line. The integer at ith location in the sequence denotes the man paired with Wi.

Sample TestCase 1

Input

3

2

= 1 2

# 3 1

Output

2 1 3

Solved
Programming in Java 1 Answer Wahab Shah

You are required to solve the N-Queen problem...

You are required to solve the N-Queen problem using a local search algorithm of your choice. You can implement your solution in the programming language of your choice.
The pseudo‐code of all the search algorithms can be found in your text‐book (i.e. AIMA). You can use the Number‐Of‐NonAttacking‐Queens as a heuristic. You are also required to measure the time required by your algorithm to find a solution as the number of N increases. For this, you can test your algorithm for 5,6 increasing values of N for e.g. you can test for N = {4, 8, 10, 20, 50, 100} 

in progress
Computer Science Capstone Project 1 Answer Asfia Rasheed

Create a Friend class in which you can store your friends' first and last names, phone numbers, a...

uploaded image

Solved
Programming in .NET 1 Answer Steve Jeff

2) Equilibrium Stage Contact for Gas-Liquid System. A gas mixture at 2.026x105 Pa total pressure ...


2) Equilibrium Stage Contact for Gas-Liquid System. A gas mixture at 2.026x105 Pa total pressure containing air and SO2 is contacted in a single-stage equilibrium mixer with pure water at 293 K. The partial pressure of SO2 in the original gas is 1.52x104 Pa. The inlet gas contains 5.70 total kg mol and the inlet water 2.20 total kg mol. The exit gas and liquid leaving are in equilibrium Calculate the amounts and compositions of the outlet phases. Use equilibrium data from Fig. 10.2-1

Solved
Chemical Engineering 1 Answer Kabelo Khenybarel

A corporation wants to invest $10 million per year for 5 years. If interest is earned at the rate...

A corporation wants to invest $10 million per year for 5 years. If interest is earned at the rate of 14 percent per year, compute the amount to which the deposits will grow if:
(a) Deposits of $10 million are made at the end of each year with interest compounded annually.
(b) Deposits of $5 million are made at the end of each 6-months period with interest compounded semiannually.

Solved
FINANCE 1 Answer Thaer Obeidat

Solid wastes from a commercial area are to be collected using a stationary- container collection ...

Solid wastes from a commercial area are to be collected using a stationary- container collection system having 4 m3 container

Solved
Civil Engineering 1 Answer Sadaf Khan

Scientific Thinking: What Role Does Peer Review Play in the Process of Science? 2 of 4 Part A - I...

Scientific Thinking: What Role Does Peer Review Play in the Process of Science? 2 of 4 Part A - Interpreting graphs 100 90 80

CH 1. The Foundations of Biology 2 of 4 Scientific Thinking: What Role Does Peer Review Play in the Process of Science? Revie

CH 1. The Foundations of Biology Scientific Thinking: What Role Does Peer Review Play in the Process of Science? 2 of 4 Reset

Solved
Biology 1 Answer Shajib Tanvir

Answer the question in C++ program. Modify the use of stack from class template to a class for si...

Answer the question in the C++ program.

Modify the use of stack from class template to a class for single dimension dynamic integer array objects (use the dynamic integer array implementation). In the driver file create 3 dynamic integer arrays of size 2, 3 and 4. Now, fill up these three arrays with user inputs. Push these arrays into a stack. Finally, print the stack.

The code for the stack is given below:

//the header file
#ifndef STACKTYPE_H_INCLUDED
#define STACKTYPE_H_INCLUDED
#include <iostream>
using namespace std;
const int MAX_ITEMS = 10;
class FullStack
// Exception class thrown
// by Push when stack is full.
{
};
class EmptyStack
// Exception class thrown
// by Pop and Top when stack is empty.
{
};
template <class ItemType>
class StackType
{
public:
StackType();
bool IsFull();
bool IsEmpty();
void Push(ItemType);
void Pop();
ItemType Top();
private:
int top;
ItemType items[MAX_ITEMS];
};
#include "stacktype.tpp"
#endif // STACKTYPE_H_INCLUDED

//the tpp file
#include "stacktype.h"
template <class ItemType>
StackType<ItemType>::StackType()
{
top = -1;
}
template <class ItemType>
bool StackType<ItemType>::IsEmpty()
{
return (top == -1);
}
template <class ItemType>
bool StackType<ItemType>::IsFull()
{
//int lastIndex = MAX_ITEMS -1;
return (top == MAX_ITEMS -1);
}
template <class ItemType>
void StackType<ItemType>::Push(ItemType newItem)
{
if(IsFull())
throw FullStack();
top++;
items[top] = newItem;
}
template <class ItemType>
void StackType<ItemType>::Pop()
{
if(IsEmpty())
throw EmptyStack();
top--;
}
template <class ItemType>
ItemType StackType<ItemType>::Top()
{
if (IsEmpty())
throw EmptyStack();
return items[top];
}

Solved
Programming in C,C++ 1 Answer Fahad Ahmed